60?

P1563 [NOIP2016 提高组] 玩具谜题

```cpp // luogu-judger-enable-o2 #include<iostream> #include<cstdio> #include<algorithm> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1; for(; ch >= '0' && ch <= '9'; ch =getchar()) x = (x << 3) + (x << 1) + (ch ^ 48); return x * f; } struct node { int dir; string name; }a[100001]; int n, m, dir, x, ans; int main() { n = read(); m = read(); for(int i = 0; i < n; ++i) a[i].dir = read(), cin >> a[i].name; ans = 0; while(m--) { dir = read(); x = read(); a[ans].dir == dir ? ans = (ans + n - x) % n : ans = (ans + x) % n; } cout << a[ans].name; return 0; } ```
by Wisbtsml @ 2018-12-09 21:20:50


不要抄袭,我挖了坑 ```cpp #include<bits/stdc++.h> using namespace std; struct wj{ string name; int cs; }a[100005]; int n,m,wz,sum,mt,mt1; int main() { ios::sync_with_stdio(false); cin>>n>>m; for(int i=0;i<n;i++)cin>>a[i].cs>>a[i].name; for(int i=1;i<=m;i++) { cin>>mt1>>mt; if(a[sum].cs==0&&mt1==0)sum=(sum+n-mt1)%n; else if(a[sum].cs==0&&mt1==1)sum=(sum+mt1)%n; else if(a[sum].cs==1&&mt1==0)sum=(sum+mt1)%n; else if(a[sum].cs==1&&mt1==1)sum=(sum+n-mt1)%n; } cout<<a[sum].name; return 0; } ```
by NKL丶 @ 2018-12-09 21:22:12


@[末命名用户6954](/space/show?uid=112661) 我的哪里错了??
by ⚡GG⚡ @ 2018-12-09 21:24:02


|