P1563 95分求原因
查看原帖
P1563 95分求原因
1494691
Theonlybreeze楼主2025/7/18 21:31

题目传送门 link

#include<bits/stdc++.h>
using namespace std;
int n, m, p = 1;
const int N = 1e5 + 5;
struct Node{
  int op;
    string name;
}doll[N];
int main() {
    cin >> n >> m;
    for(int i = 1; i <= n; i ++) cin >> doll[i].op >> doll[i].name;
    if(n == 1) {
        cout << doll[1].name;
        return 0;
    }
    for(int i = 1; i <= m; i ++) {
        int way, s;
        cin >> way >> s;
        if(doll[p].op == 0) way = 1 - way; 
        if(way == 0) { 
            p += s;
            if(p > n) p %= n;
        }
        else { 
            p -= s;
            if(p < 0) p = n + p;
        }
    } cout << doll[p].name;
    return 0;
}

各位大佬,帮我看看,我95分,样例4不过是为什么???急急急

2025/7/18 21:31
加载中...