QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#149964 | #5602. Sun and Moon | MegaSam | WA | 2ms | 5976kb | C++14 | 1.4kb | 2023-08-25 14:42:07 | 2023-08-25 14:42:08 |
Judging History
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'