[构造] Codeforces Gym 100553 NEERC 14 E. Epic Win!
来源:互联网 发布:如何破解php源码 编辑:程序博客网 时间:2024/05/08 02:48
一道神奇的题 题目大意给你一个剪刀石头布自动机 然后让你构造一个剪刀石头布自动机克制他
这个我们先构造出一个完全针对他的自动机
然后我们开始枚举起点一起跑 用双方所在节点
当前状态的转移遍不存在时 我们就把这条边连向
如果成环了 那么一定是在一个
ps.似乎有一个乱搞做法 没仔细看
#include<cstdio>#include<cstdlib>#include<algorithm>using namespace std;#define read(x) scanf("%d",&(x))const int N=50005;int n;int a[N][4],b[N][4],c[N][4];int tot;inline void pb(){ for (int i=1;i<=n;i++){ c[tot*n+i][0]=b[i][0]; for (int j=1;j<=3;j++) if (b[i][j]) c[tot*n+i][j]=b[i][j]+tot*n; } ++tot;}int vst[N][105];int clk;int main(){ char _c; freopen("t.in","r",stdin); freopen("t.out","w",stdout); read(n); for (int i=1;i<=n;i++){ do _c=getchar(); while (!(_c>='A' && _c<='Z')); a[i][0]=_c=='R'?1:(_c=='P'?2:3); read(a[i][1]); read(a[i][2]); read(a[i][3]); } for (int i=1;i<=n;i++){ b[i][0]=a[i][0]%3+1; b[i][1]=b[i][2]=b[i][3]=0; b[i][a[i][0]]=a[i][b[i][0]]; } pb(); for (int i=2;i<=n;i++){ ++clk; int x=1,y=i; while (1){ if (vst[x][y]==clk) break; vst[x][y]=clk; if (!c[x][a[y][0]]){ pb(); c[x][a[y][0]]=n*(tot-1)+a[y][c[x][0]]; break; } int t=x; x=c[x][a[y][0]]; y=a[y][c[t][0]]; } } printf("%d\n",n*tot); for (int i=1;i<=n*tot;i++){ putchar(c[i][0]==1?'R':(c[i][0]==2?'P':'S')); for (int j=1;j<=3;j++) printf(" %d",c[i][j]==0?1:c[i][j]); printf("\n"); } return 0;}
阅读全文
0 0
- [构造] Codeforces Gym 100553 NEERC 14 E. Epic Win!
- Problem E. Epic Win!
- [构造] Codeforces Gym 101190 NEERC 16 C. Cactus Construction
- Gym-100712E-Epic Professor
- Gym 100712E Epic Professor
- GYM 100712 E.Epic Professor(水~)
- [扫描线 杂题] Codeforces Gym 101190 NEERC 16 E. Expect to Wait
- [三分套三分] Codeforces Gym 100307 NEERC 13 E. Easy Geometry
- Codeforces Gym 101190 (NEERC 2016) E. Expect to Wait (扫描线)
- Codeforces Gym 101190 (NEERC 2016) A. Abbreviation
- CodeForces Gym 100735E
- Codeforces gym 100685 E
- codeforces [Gym-100814E]
- Codeforces gym 101243 E
- Gym 100685E Epic Fail of a Genie(贪心)
- [可图性判定 Havel-Hakimi定理 构造] Codeforces Gym 100269 NEERC 13 Northern K. Kids in a Friendly Class
- codeforces-gym-100187-E【bfs】
- [物理 杂题] Codeforces Gym 101190 NEERC 16 J. Jenga Boom
- 关于synchronized 特别需要强调的一个点!!
- 一共有20级楼梯,每次可以上1级或2级,登上第20级一共有多少种上法
- 基于STM32wifi小车制作(二)-电源设计
- jsp forward指令
- Radar Installation(POJ-1328)
- [构造] Codeforces Gym 100553 NEERC 14 E. Epic Win!
- jsp param
- Codevs1993草地排水
- 后台登陆地址大全
- angularjs 控件
- queue与stack遇到的错误
- 解决:由于目标计算机积极拒绝 无法连接
- ES6语法(6)
- [bzoj] 1082: [SCOI2005]栅栏