[交互] Codeforces Gym101190 NEERC2016I. Indiana Jones and the Uniform Cave
来源:互联网 发布:get it 编辑:程序博客网 时间:2024/05/22 13:28
题目要求我们遍历一遍图
可以用石子的三种状态表示这个点的状态(Center未访问、Right在栈中、Left不在栈中)
从一个点开始遍历,把石子放在当前遍历的边的Right,如果没访问到的点没访问过就继续。
如果访问到的点在栈中,那么我们就沿着石子的那条边走,顺便把石子放在Left,这样走到的第一个石子在Left的点说明我们走回去了,记一下之前走了几步,再走一遍就来了
如果不在栈中,那么一直沿着石子走,走到栈中,再用上面的方法做就行了。
遍历完要回到父亲,用上面的方法求出low,再回到父亲
#include <cstdio>#include <iostream>#include <algorithm>#include <cstring>using namespace std;const int C=0,L=1,R=2;inline int nxt(int a,int b,int c){ cout<<a<<' '<<(b==L?"left":"right")<<' '<<c<<endl; string ret; cin>>ret; if(ret=="center") return C; else if(ret=="left") return L; else if(ret=="right") return R; exit(0);}string aa;int main(){ int m; cin>>m; cin>>aa; while(1){ int cb=0,p,lst=0; for(int t=1;t<=m;t++){ int cur=nxt(1,R,1); if(cur==C){ cb=1; break; } int lnum=0,rnum=0; while(cur==L) cur=nxt(0,L,0),lnum++; while(cur==R) cur=nxt(0,L,0),rnum++; if(rnum>lst) lst=rnum,p=t; for(int i=1;i<=lnum;i++) nxt(0,L,0); for(int i=1;i<rnum;i++) nxt(0,R,0); } if(cb) continue; int cur=nxt(p%m,L,p%m); while(cur==L) cur=nxt(0,L,0); for(int i=1;i<lst-1;i++) nxt(0,R,0); }}
阅读全文
0 0
- [交互] Codeforces Gym101190 NEERC2016I. Indiana Jones and the Uniform Cave
- [杂题 交互] Codeforces Gym 101190 NEERC 16 I. Indiana Jones and the Uniform Cave
- zoj 1519 || poj 1292 Will Indiana Jones Get There?
- POJ 1292 Will Indiana Jones Get There? 笔记
- [博弈] Codeforces Gym101190 NEERC2016G. Game on Graph
- codeforces ice cave
- Ice Cave CodeForces
- [模拟费用流] Codeforces Gym101190 NEERC2016M. Mole Tunnels
- 【bzoj4151】 [AMPPZ2014]The Cave
- 【AMPPZ2014】【BZOJ4151】The Cave
- CodeForces 540C Ice Cave
- Face Detection[Jones & Viola] and Localization
- URAL 1553【CAVE and TUNNEL】
- 《the cave》攻略及感悟
- [BZOJ]4151: [AMPPZ2014]The Cave
- CodeForces The Child and Set
- Chloe and the sequence CodeForces
- Chloe and the sequence CodeForces
- day2
- Android设计模式之MVP
- Xcode9学习笔记18
- [deeplearning-002] 单节点神经网络推导
- ios-ios11去除Social Framework
- [交互] Codeforces Gym101190 NEERC2016I. Indiana Jones and the Uniform Cave
- BZOJ4403 序列统计
- 用栈将十进制数转行成二进制数
- 二级列表和全选
- Visual Studio 命令行安装方法及离线下载安装包
- BZOJ2982 combination
- 第七周 【项目1
- codevs 1174 靶形数独 (启发式搜索)
- Django 登陆VIEW