洛谷P1563 [NOIP2016 提高组] 玩具谜题进阶解法
作者:互联网
#include<cstdio>
#include<cstdlib>
struct Man
{
int f1;
int f2;
int s;
char g[10];
};
int main(void)
{
int i,j,k,N, M;
Man* p=(Man*)malloc(sizeof(Man)*100000);
scanf("%d%d", &N, &M);
for (i = 0; i < N; i++)
scanf("%d%s", &(p + i)->f1, (p + i)->g);
for (i=0,j=0;j<M;j++)
{
scanf("%d%d", &(p+i)->f2, &(p+i)->s);
k = (p+i)->s;
if ((p+i)->f1 != (p+i)->f2)
i = (i+(*(p + i)).s) % N;
else
i = (i+N-(*(p + i)).s) % N;
}
printf("%s",(p+i)->g);
free(p);
return 0;
}
标签:NOIP2016,f2,洛谷,进阶,f1,int,scanf,d%,Man 来源: https://blog.csdn.net/weixin_52075219/article/details/114394943