萌新,求助

Xrzzzzzz edited 3 年,8 月前

用题目给的例子测试是对的,但是一提交第一个测试点都过不去…为什么?

/*
 * @Description: 
 * @Autor: Tim
 * @Date: 2021-03-13 16:43:40
 * @LastEditors: Tim
 * @LastEditTime: 2021-03-13 18:16:39
 */
#include <iostream>
using namespace std;

typedef struct problem_3
{
    int a;         //编号
    char name[10]; //名字
} player;

int main()
{
    int p, m;
    cin >> p >> m;
    player pe[100000];
    for (int i = 0; i < p; i++)
    {
        cin >> pe[i].a >> pe[i].name;
    }
    int index = 0;
    for (int i = 0; i < m; i++)
    {
        int x, y;
        cin >> x >> y;
        if (pe[index].a)
        { //朝向圈外
            if (!x)
            { //向左
                index = (index + y) % p;
            }
            else
            {
                if (index > y)
                {
                    index = (index - y) % p;
                }
                else
                {
                    index = p - (y - index) % p;
                }
            }
        }
        else
        { //朝向圈内
            if (!x)
            { //想左
                if (index > y)
                {
                    index = (index - y) % p;
                }
                else
                {
                    index = p - (y - index) % p;
                }
            }
            else
            {
                index = (index + y) % p;
            }
        }
    }
    printf("%s\n", pe[index].name);
  //  system("Pause");
    return 0;
}

Comments