mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-08 02:13:51 +08:00
Add FZOI Codes
This commit is contained in:
34
FZOI/「NOIP2016」玩具谜题.cpp
Normal file
34
FZOI/「NOIP2016」玩具谜题.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include<cstdio>
|
||||
using namespace std;
|
||||
const int MAXN = 100010;
|
||||
|
||||
int n, m;
|
||||
struct TOY{
|
||||
int pos;
|
||||
char name[100];
|
||||
};
|
||||
TOY toy[MAXN];
|
||||
|
||||
int main()
|
||||
{
|
||||
scanf("%d%d", &n, &m);
|
||||
for (int i = 1; i <= n; i ++ ) scanf("%d%s", &toy[i].pos, &toy[i].name);
|
||||
int now = 1;
|
||||
int zy, s;
|
||||
for (int i = 1; i <= m; i ++ )
|
||||
{
|
||||
scanf("%d%d", &zy, &s);
|
||||
if ((toy[now].pos == 0 && zy == 1) || (toy[now].pos == 1 && zy == 0))
|
||||
{
|
||||
now += s;
|
||||
if (now > n) now = now % n;
|
||||
}
|
||||
else
|
||||
{
|
||||
now -= s;
|
||||
if (now <= 0) now = n + now;
|
||||
}
|
||||
}
|
||||
printf("%s", toy[now].name);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user