您的位置:首页 > 其它

2015.10.20 福州大学第九届程序设计竞赛

2015-10-22 00:49 274 查看
FZU 2086 餐厅点餐

枚举

练的时候以为是dp---(事实上这场只做了10来分钟---就愉快地滚去吃饭了---)

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
using namespace std;

stack<int> r;//播放记录
int n,m;

void solve(){
while(!r.empty()) r.pop();
char op[15];
int x;
r.push(1);
for(int i = 1;i <= m;i++){
scanf("%s",op);
if(op[1] == 'R'){
int y = r.top();r.pop();
//    printf("y = %d\n",y);
if(r.empty()){
puts("1");
r.push(1);
}
else{
int z = r.top();r.pop();
printf("%d\n",z);
if(!r.empty()) {
int zz = r.top();
if(z != zz) r.push(z);
}
else r.push(z);
}
}
if(op[1] == 'E'){
int y = r.top();
if(y < n){
y++;
r.push(y);
}
printf("%d\n",y);

}
if(op[1] == 'L'){
scanf("%d",&x);
printf("%d\n",x);

if(!r.empty()) {
int zz = r.top();
if(x != zz) r.push(x);
}
else r.push(x);
}
}
}

int main(){
int T;
scanf("%d",&T);
while(T--){
scanf("%d %d",&n,&m);
solve();
}
return 0;
}


View Code

FZU 2092 收集水晶

FZU 2093 寻找兔子
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: