两评四色,55分,蒟蒻自闭
查看原帖
两评四色,55分,蒟蒻自闭
320697
AMIRIOX無暝楼主2020/4/30 03:06

第一次记录 经查RE是因为数组没开够

第二次记录 他怎么TLE的呢

代码:

注:system("pause")只在Windows下有效,不会卡洛谷测评机

#include <bits/stdc++.h>
using namespace std;

int n, m;

struct person {
    /* data */
    int ind;
    string zy;
} per[1000001];

int main() {
    scanf("%d %d", &n, &m);
    int cur = 0;
    for (int i = 0; i < n; i++) {
        cin >> per[i].ind >> per[i].zy;
    }
    for (int i = 0; i < m; i++) {
        int fx, step;
        scanf("%d %d", &fx, &step);
        if (fx == 0) {
            int flag = ((per[cur].ind==0)?-1:1);
            while (step--) {
                if (cur < 0) cur = n - 1;
                cur+=flag;
            }
        } else if (fx == 1) {
            int flag = ((per[cur].ind==0)?-1:1);
            while (step--) {
                if (cur == n) cur = 0;
                cur-=flag;
            }
        }
    }
    puts(per[cur].zy.c_str());
    system("pause");
    return 0;
}
2020/4/30 03:06
加载中...