1 solutions
-
0
基础模拟题,我们可以逆时针将所有的职业连起来,然后然后根据谜题进行操作,为什么方便操作可以我们固定谜题中的职业移动的方向.
#include<bits/stdc++.h> using namespace std; const int N=1e5+10; int dir[N]; string name[N]; int main() { int n,m; cin>>n>>m; for(int i=0;i<n;i++) { cin>>dir[i]>>name[i]; } int x=0; while(m--) { int a,s; cin>>a>>s; if(a==1) s=-s;//强制向左 if(dir[x]==1) x+=s;//圈外的左边(逆时针走) else x-=s; x=(x+n)%n; //cout<<x<<" "<<s<<" "<<n<<endl; } cout<<name[x]; return 0; }
- 1
Information
- ID
- 1118
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 10
- Tags
- # Submissions
- 1
- Accepted
- 1
- Uploaded By