```#include<bits/stdc++.h>···
```using namespace std;···
```long hand[100000],n,m,a,b,c;
```char name[100000][15];
```int main()
```{
```cin>>n>>m;```
```for(int i=1;i<=n;i++)
```cin>>hand[i]>>name[i];
```a=1;
```for(int i=1;i<=m;i++)
```{
``` cin>>b>>c;
``` if(hand[a]==b)
``` a=a-c;
``` else a=a+c;
``` if(a<=0) a=a+n;
``` if(a>n) a=a-n;
}
cout<<name[a]<<endl;
}\\麻烦dalao
by 莲、阿修贝尔 @ 2018-10-31 21:18:30
一直都是re,改小了又是错误,怎么办
by 莲、阿修贝尔 @ 2018-10-31 21:19:34
@[莲、阿修贝尔](/space/show?uid=107928) 用string吧
by Ein_Niemand @ 2018-11-04 09:24:32
试过了,不行啊
by 莲、阿修贝尔 @ 2018-11-04 20:30:35
@[Nature](/space/show?uid=122407) 试过了,不行啊
by 莲、阿修贝尔 @ 2018-11-04 20:31:18
@[莲、阿修贝尔](/space/show?uid=107928) 不好意思,现在才看到。
改成这样试试:
```cpp
if(hand[a]==b) a=(a+n-c)%n;
else a=(a+c)%n;
if(a==0) a=n;
```
by Ein_Niemand @ 2018-11-05 22:03:21
@[莲、阿修贝尔](/space/show?uid=107928)
并且把数组开大一点:
```cpp
hand[100005],n,m,a,b,c;
char name[100005][15];
//你有可能因为这个会RE
```
by Ein_Niemand @ 2018-11-05 22:07:30
@[莲、阿修贝尔](/space/show?uid=107928)
RE是因为数组范围太小(也就是访问了数组范围以外的下标:因为你开的是100000的数组,即数组大小为100000,所以数组范围为**0-99999**(因为普通数字数组下标**从0开始**))
**所以**一般**你开数组是可以把它范围开到(maxn(数据范围最大值)+5)**
或者是因为访问了负数下标(比如hand[-1],不过你这里没有,主要因为前者才RE)
以后学深入就明白了
by Ein_Niemand @ 2018-11-05 22:17:10
@[莲、阿修贝尔](/space/show?uid=107928)
这是改之前的
![](https://cdn.luogu.com.cn/upload/pic/42308.png)
------------------------
------------------------
------------------------
这是改之后的
![](https://cdn.luogu.com.cn/upload/pic/42310.png)
by Ein_Niemand @ 2018-11-05 22:20:43
@[Nature](/space/show?uid=122407) 谢谢啊
by 莲、阿修贝尔 @ 2018-11-08 19:16:42