QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#133748 | #4934. Forbidden Card | S_Explosion# | WA | 13ms | 12856kb | C++20 | 1.6kb | 2023-08-02 13:50:58 | 2023-08-02 13:51:00 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
template <typename Tp>
inline void read(Tp &x) {
x = 0;
bool f = true; char ch = getchar();
for ( ; ch < '0' || ch > '9'; ch = getchar()) f ^= ch == '-';
for ( ; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + (ch ^ 48);
x = f ? x : -x;
}
const int N = 1e5, M = 1e6;
bool vis[M + 5];
int a[N + 5], b[N + 5], iter[M + 5], f[M + 5], ans[N + 5];
std::vector<std::pair<int, int> > Vec;
int main() {
int n, m;
read(n), read(m);
for (int i = 1; i <= n; ++i) read(a[i]), read(b[i]);
int now = 1, lose;
while (1) {
if (!vis[a[now]]) {
vis[a[now]] = true;
Vec.push_back(std::make_pair(a[now], now));
iter[a[now]] = (int)Vec.size() - 1;
}
else if (!vis[b[now]]) {
vis[b[now]] = true;
Vec.push_back(std::make_pair(b[now], now));
iter[b[now]] = (int)Vec.size() - 1;
}
else {
lose = now;
break;
}
now = now % n + 1;
}
ans[lose] += m - (int)Vec.size();
for (int i = 1; i <= m; ++i) f[i] = lose;
for (int i = (int)Vec.size() - 1; i >= 0; --i) {
std::pair<int, int> pii = Vec[i];
int w = pii.first, pos = pii.second;
if (w == b[pos] || iter[b[pos]] < i) {
f[w] = pos;
}
else {
f[w] = f[b[pos]];
}
++ans[f[w]];
}
for (int i = 1; i <= n; ++i) printf("%d\n", ans[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 7752kb
input:
3 6 1 2 2 4 4 2
output:
3 0 3
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 2ms
memory: 7700kb
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: 0ms
memory: 5700kb
input:
1 2 1 2
output:
2
result:
ok single line: '2'
Test #4:
score: -100
Wrong Answer
time: 13ms
memory: 12856kb
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'