QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#686681#4934. Forbidden CardSanguineChameleon#WA 8ms11312kbC++201.5kb2024-10-29 15:09:302024-10-29 15:09:30

Judging History

你现在查看的是最新测评结果

  • [2024-10-29 15:09:30]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:11312kb
  • [2024-10-29 15:09:30]
  • 提交

answer

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

void justDoIt();

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    justDoIt();
    return 0;
}

const int MAX_N = 2e5 + 20;
const int MAX_M = 1e6 + 20;
int a[MAX_N][2];
int pos[MAX_M];
int played[MAX_M];
int dp[MAX_M];
int res[MAX_N];

void justDoIt() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> a[i][0] >> a[i][1];
    }
    int cnt = 0;
    for (int turn = 1; turn <= n * 2 + 1; turn++) {
        int player = (turn - 1) % n + 1;
        for (int j = 0; j < 2; j++) {
            int x = a[player][j];
            if (!pos[x]) {
                played[turn] = x;
                pos[x] = turn;
                break;
            }
        }
        if (played[turn]) {
            cnt++;
        }
        else {
            for (int x = 1; x <= m; x++) {
                if (!pos[x]) {
                    dp[x] = player;
                }
            }
            break;
        }
    }
    for (int turn = cnt; turn >= 1; turn--) {
        int player = (turn - 1) % n + 1;
        if (played[turn] == a[player][1]) {
            dp[played[turn]] = player;
        }
        else if (pos[a[player][1]] < turn) {
            dp[played[turn]] = player;
        }
        else {
            dp[played[turn]] = dp[a[player][1]];
        }
    }
    for (int i = 1; i <= m; i++) {
        res[dp[i]]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << res[i] << '\n';
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 7724kb

input:

3 6
1 2
2 4
4 2

output:

3
0
3

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 7660kb

input:

4 10
1 5
2 6
3 7
4 8

output:

4
2
2
2

result:

ok 4 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 7652kb

input:

1 2
1 2

output:

2

result:

ok single line: '2'

Test #4:

score: -100
Wrong Answer
time: 8ms
memory: 11312kb

input:

69332 250102
51362 228823
206751 31351
181790 44202
186695 92215
172072 173179
86663 76959
42382 25827
204750 30001
42502 11959
201030 71886
227497 216114
164282 235028
178967 181951
125356 20611
169528 174071
50985 175562
63676 208400
189134 229462
49746 131529
180236 247427
29278 229589
30381 4412...

output:

180770
1
1
1
1
1
0
1
0
1
0
0
1
0
1
1
0
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
0
1
1
1
0
1
1
1
1
0
1
1
1
1
0
1
1
1
1
1
1
1
0
1
0
1
0
0
1
1
1
1
1
1
1
1
1
0
1
0
1
1
1
1
1
1
1
0
1
1
1
0
0
1
1
1
1
1
1
1
1
0
1
1
0
0
0
0
1
1
1
1
0
0
0
1
1
1
0
1
1
1
0
1
0
0
1
0
1
0
1
1
0
1
1
0
1
1
1
0
0
0
1
1
1
0
0
1
1
1
1
0
0...

result:

wrong answer 1st lines differ - expected: '197458', found: '180770'