QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#149964#5602. Sun and MoonMegaSamWA 2ms5976kbC++141.4kb2023-08-25 14:42:072023-08-25 14:42:08

Judging History

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

  • [2023-08-25 14:42:08]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5976kb
  • [2023-08-25 14:42:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 5;
const int M = 1000000 + 5;
int n, m, a[N], b[N];
int simul[N << 1], tot;
char vis[M], cardTy[N];
int lp[M], ep[N << 1], ans[N];
int main() {
    // freopen("marketplace.in", "r", stdin);
    // freopen("marketplace.out", "w", stdout);
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i ++) {
        scanf("%d%d", a + i, b + i);
        if (tot == i - 1) {
            if (!vis[a[i]]) {
                vis[a[i]] = 1;
                simul[++ tot] = a[i];
            }else if (!vis[b[i]]) {
                vis[b[i]] = 1;
                simul[++ tot] = b[i];
                cardTy[i] = 1;
            }
        }
    }
    if (tot == n) {
        for (int i = 1; i <= n; i ++) {
            if (cardTy[i] || vis[b[i]]) {
                break;
            }
            vis[b[i]] = 1;
            simul[++ tot] = b[i];
        }
    }
    for (int i = tot; i > 0; i --) {
        lp[simul[i]] = i;
        if (i > n || cardTy[i] || vis[b[i]]) {
            ans[i > n ? i - n : i] ++;
            ep[i] = i > n ? i - n : i;
        }else {
            ep[i] = ep[lp[b[i]]];
            int p = ep[i];
            ans[p] ++;
        }
        vis[simul[i]] = 0;
    }
    ans[tot % n + 1] += ans[0] + m - tot;
    for (int i = 1; i <= n; i ++) printf("%d\n", ans[i]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 5976kb

input:

3 10
1 2

output:

0
1
9

result:

wrong answer 1st lines differ - expected: '7', found: '0'