标签:des style blog color os io for art
#include <cstdio> #include <iostream> #define N 500005 using namespace std; int now[N],tot_ro,c,p; int stack[N],pre[N],tot; int stack_ne[N],now_ne[N],next[N],tot_ne; char order[100]; int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF){ tot=tot_ne=0; tot_ro=1; now[1]=now_ne[1]=0; for(int i=0; i<n; i++){ scanf("%s",order); switch (order[4]) { case ‘n‘://learn scanf("%d%d",&c,&p); stack[++tot]=p; pre[tot]=now[c]; now[c]=tot; now_ne[c]=0; break; case ‘b‘://rollback scanf("%d",&c); if(now[c]!=0){ stack_ne[++tot_ne]=stack[now[c]]; next[tot_ne]=now_ne[c]; now_ne[c]=tot_ne; now[c]=pre[now[c]]; } break; case ‘a‘://relearn scanf("%d",&c); if(now_ne[c]!=0){ stack[++tot]=stack_ne[now_ne[c]]; pre[tot]=now[c]; now[c]=tot; now_ne[c]=next[now_ne[c]]; } break; case ‘e‘://clone scanf("%d",&c); if(c<=tot_ro){ now[++tot_ro]=now[c]; now_ne[tot_ro]=now_ne[c]; } break; case ‘k‘://check scanf("%d",&c); if(now[c]==0) printf("basic\n"); else printf("%d\n",stack[now[c]]); break; } } } return 0; }
标签:des style blog color os io for art
原文地址:http://www.cnblogs.com/Mathics/p/3873877.html