题目如上描述,思路是如果小人的朝向与查询的方向相同就减,不同就加,然后直接模拟。
毕竟是day1T1还比较简单。
附AC代码:
#include<cstdio>
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
const int maxn = 1e5+5;
int n,m;
int dic,len;
int tws[maxn];
char mz[maxn][15];
template <class T> inline void read(T &xx)
{
xx = 0;
T flag = 1;
char ch = (char)getchar();
while(ch<'0' || ch>'9')
{
if(ch == '-') flag = -1;
ch = (char)getchar();
}
while(ch>='0' && ch<='9')
{
xx = (xx<<1) + (xx<<3) + ch - '0';
ch = (char)getchar();
}
xx *= flag;
}
int main()
{
freopen("toy.in","r",stdin);
freopen("toy.out","w",stdout);
int now = 1,len;
read(n); read(m);
for(int i = 1; i <= n; i++)
{
read(tws[i]);
scanf("%s",mz[i]);
}
while(m--)
{
read(dic); read(len);
if(dic == tws[now])
{
if(now > len) now -= len;
else now = n-len+now;
}
else if(dic != tws[now])
{
if(now+len > n) now = len+now-n;
else now = len+now;
}
}
for(int i = 0; i < strlen(mz[now]); i++)
printf("%c",mz[now][i]);
return 0;
}