题目传送门

#include <bits/stdc++.h>

using namespace std;
int n, m;
const int N = 1e5 + 10;
struct Node {
    int dir;    //方向,0:圈内,1:圈外
    string name;//姓名
} c[N];

int main() {
    //读入数据
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        cin >> c[i].dir >> c[i].name;
    //出发点
    int k = 0;
    while (m--) {
        //a==0 ,表示向左数 s 个人
        //a==1 ,表示向右数 s 个人
        int a, s;
        cin >> a >> s;
        if (a == 0 && c[k].dir == 0) k = (k - s + n) % n; //向前找
        else if (a == 0 && c[k].dir == 1) k = (k + s) % n;//向后找
        else if (a == 1 && c[k].dir == 0) k = (k + s) % n;//向后找
        else if (a == 1 && c[k].dir == 1) k = (k - s + n) % n;  //向前找
    }
    printf("%s", c[k].name.c_str());
    return 0;
}

相关文章:

  • 2022-01-18
  • 2021-10-19
  • 2021-12-23
  • 2021-10-04
  • 2021-10-03
  • 2021-10-01
  • 2022-12-23
猜你喜欢
  • 2022-02-11
  • 2021-08-06
  • 2021-08-12
  • 2021-11-24
  • 2021-07-08
  • 2021-07-27
  • 2021-10-26
相关资源
相似解决方案