求助,为什么值得了90分?

P1563 [NOIP2016 提高组] 玩具谜题

~~开`long long`?~~
by a2lyaXNhbWUgbWFyaXNh @ 2022-08-01 15:49:42


@[S__B](/user/661595) 貌似跟 long long 没有关系
by andygao @ 2022-08-01 15:55:51


@[andygao](/user/542705) 我也是90,不知道为什么
by Low_key_smile @ 2022-08-08 08:52:06


要从0开始,不然会wa
by fanjikai @ 2022-08-10 12:43:22


temp和输入小人的for循环都从0开始就好了
by fanjikai @ 2022-08-10 12:47:04


temp初始值从0开始, 另外 ```cpp for(int i = 0;i<n;i++){ cin>>toy[i].cx>>toy[i].zy; }for(int i = 0;i<m;i++){ int a,s; cin>>a>>s; temp = b(a,s,temp); } ``` 循环也从零开始 AC Code: ```cpp #include <bits/stdc++.h> using namespace std; int n,m,temp = 0; struct t{ int cx; string zy; }toy[100009]; int b(int x,int y,int temp){ if(toy[temp].cx==0){ if(x==0){ temp = (temp-y+n)%n; }else{ temp += y; temp %= n; } }else{ if(x==0){ temp += y; temp %= n; }else{ temp = (temp-y+n)%n; } } return temp; } int main(){ cin>>n>>m; for(int i = 0;i<n;i++){ cin>>toy[i].cx>>toy[i].zy; } for(int i = 0;i<m;i++){ int a,s; cin>>a>>s; temp = b(a,s,temp); }cout<<toy[temp].zy; } ```
by Mr_Ma666 @ 2022-08-10 12:49:55


|