http://acm.sgu.ru/problem.php?contest=0&problem=397
模拟链表 ,坑惨了我 ,自己模拟链表 出错 wa了 好久
#include<stdio.h> #include<string.h> const int maxn=1000005; char str[maxn],T[maxn]; int per[maxn],next[maxn]; int main(){ int n; while(scanf("%s",str)==1){ n=strlen(str); int S=0,L=0;per[0]=next[0]=-1; for(int i=0;i<n;i++){ if(str[i]>='a'&&str[i]<='z'){ L++; T[L]=str[i]; per[L]=S; if(next[S]!=-1){ per[next[S]]=L; } next[L]=next[S]; next[S]=L; S=L; } else { if(str[i]=='L'&&per[S]!=-1) S=per[S]; if(str[i]=='R'&&next[S]!=-1) S=next[S]; } } S=next[0]; while(S!=-1) { printf("%c",T[S]); S=next[S]; } printf(" "); } return 0; }