求调必关
查看原帖
求调必关
1063062
lihuohua楼主2025/7/22 20:12
#include<bits/stdc++.h>
using namespace std;

struct people {
    bool toward;
    string name;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int m;
    cin >> n >> m;
    people a[n];
    int nown = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a[i].toward >> a[i].name;
    }
    for(int i = 0; i < m; ++i) {
        bool to;
        int x;
        cin >> to >> x;
        if(to == 0 && a[nown].toward == 0) {
            nown = nown - x;
        }
        if(to == 0 && a[nown].toward == 1) {
            nown = nown + x;
        }
        if(to == 1 && a[nown].toward == 1) {
            nown = nown - x;
        } 
        if(to == 0 && a[nown].toward == 1) {
            nown = nown + x;
        }
        if(nown < 0) {
            nown = -nown;
        }
        nown = nown % n;
    }
    cout << a[nown].name;
    return 0;
}
2025/7/22 20:12
加载中...