调+写了2个小时 有点崩溃 20AC 40WA 40TLE,玄3关
#include<bits/stdc++.h>
using namespace std;
stack<long long>s0,s1;
long long x,y,num,top1,top0,cha;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
char op[10];
while(scanf("%s",op)!=EOF) {
bool ff=false;
if(strcmp(op,"PUSH")==0) {
scanf("%lld%lld",&x,&num);
if(x==0)s0.push(num);
else s1.push(num);
} else if(strcmp(op,"POP")==0) {
scanf("%lld",&x);
if(x==0) {
if(s0.empty())ff=true;
else s0.pop();
} else {
if(s1.empty())ff=true;
else s1.pop();
}
} else if(strcmp(op,"ADD")==0) {
scanf("%lld",&x);
if(s0.empty()||s1.empty())ff=true;
else {
top0=s0.top();
top1=s1.top();
s0.pop();
s1.pop();
if(x==0)s0.push(top0+top1);
else s1.push(top0+top1);
}
} else if(strcmp(op,"SUB")==0) {
scanf("%lld",&x);
if(s0.empty()||s1.empty())ff=true;
else {
top0=s0.top();
top1=s1.top();
s0.pop();
s1.pop();
cha=abs(top0-top1);
if(x==0)s0.push(cha);
else s1.push(cha);
}
} else if(strcmp(op,"DEL")==0) {
scanf("%lld",&x);
if(x==0)while(!s0.empty())s0.pop();
else while(!s1.empty())s1.pop();
} else if(strcmp(op,"MOVE")==0) {
scanf("%lld%lld",&x,&y);
if(x==0&&y==1)while(!s1.empty()) {
top0=s1.top();
s0.push(top0);
s1.pop();
}
else if(x==1&&y==0)while(!s0.empty()) {
top0=s0.top();
s1.push(top0);
s0.pop();
}
} else if(strcmp(op,"SWAP")==0)swap(s0,s1);
else if(strcmp(op,"AKIOI")==0);
else if(strcmp(op,"END")==0) {
if(s0.empty())cout<<"NONE\n";
else {
cout<<"SUCCESS\n";
while(!s0.empty()) {
cout<<s0.top()<<" ";
s0.pop();
}
cout<<"\n";
}
if(s1.empty())cout<<"NONE\n";
else {
cout<<"SUCCESS\n";
while(!s1.empty()) {
cout<<s1.top()<<" ";
s1.pop();
}
cout<<"\n";
}
return 0;
}else ff=true;
if(ff)cout<<"UNSUCCESS\n";
else cout<<"SUCCESS\n";
}
return 0;
}