0分求调
查看原帖
0分求调
912394
LuoguAdministrator楼主2024/5/19 20:30
#include <bits/stdc++.h>
#define PI acos(-1.0)
#define int long long
#define N 100010
using namespace std;

inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return x*f;
}

inline void write(int x){
    if(x==0){putchar('0');return;}
    if(x<0){putchar('-');x=-x;}
    char num[21];
	int top=0;
    while(x){num[++top]=(x%10)^'0';x/=10;}
    while(top)putchar(num[top--]);
}

deque<int> dq;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n,k,x=0;
    char a,b;
    n=read();
	for(int i=0;i<n;i++){
  		cin>>a>>b;
	    if(a=='A'&&b=='L') dq.push_front(++x);
		else if(a=='A'&&b=='R') dq.push_back(++x);
		else if(a=='D'&&b=='L'){
	        k=read();
	        for(int j=0;j<k;j++) dq.pop_front();
	    }else{
				k=read();
	        for(int j=0;j<k;j++) dq.pop_back();
	    }
	}while(!dq.empty()){
		write(dq.front());
		cout<<endl;
		dq.pop_front();
	}return 0;
}
2024/5/19 20:30
加载中...