QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#133756 | #4934. Forbidden Card | S_Explosion# | WA | 17ms | 13968kb | C++20 | 1.6kb | 2023-08-02 13:53:29 | 2023-08-02 13:53:31 |
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]) {
f[w] = pos;
}
else {
if (!iter[b[pos]]) f[w] = lose;
else if (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;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 7912kb
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: 7696kb
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: 2ms
memory: 9812kb
input:
1 2 1 2
output:
2
result:
ok single line: '2'
Test #4:
score: 0
Accepted
time: 9ms
memory: 12800kb
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:
197458 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 69332 lines
Test #5:
score: 0
Accepted
time: 6ms
memory: 13196kb
input:
80145 426253 421996 34366 346502 239646 343011 88629 67397 242186 299496 244930 21243 104718 387596 328535 219758 313693 75331 382300 313805 77098 42577 148653 337458 118115 214642 386869 250381 179903 371620 42703 175776 57872 382478 385425 67153 363632 137021 301439 54496 28984 416540 87624 180610...
output:
2 2 387645 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 80145 lines
Test #6:
score: -100
Wrong Answer
time: 17ms
memory: 13968kb
input:
100000 1000000 123135 548518 73705 792839 425849 331898 823140 91484 612409 674530 215766 587078 145133 904035 435464 107690 291461 358251 156778 270843 378425 339959 353997 687100 373365 903063 948343 203641 349073 91866 329756 348161 731516 202789 767371 938875 3496 388919 998073 384450 73693 8551...
output:
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 956617 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
wrong answer 25th lines differ - expected: '956616', found: '956617'