QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#724089 | #4934. Forbidden Card | winsun | WA | 4ms | 3828kb | C++14 | 1.4kb | 2024-11-08 09:28:03 | 2024-11-08 09:28:03 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <queue>
#include <utility>
#define fi first
#define se second
using namespace std;
typedef long long LL;
template <typename Tp> inline void read(Tp& x) {
char ch; bool op = 0; x = 0;
do ch = getchar(), op |= ch == '-'; while (ch < '0' || ch > '9');
do x = (x<<3)+(x<<1)+(ch&15), ch = getchar(); while (ch >= '0' && ch <= '9');
if (op) x = -x;
}
bool Mst;
const int MAXN = 1e5+5;
const int MAXM = 1e6+5;
int n, m, a[MAXN], b[MAXN];
int use[MAXM], tar[MAXN<<1], cnt[MAXN];
bool Med;
void solve() {
for (int _ = 0; _ < 2; ++_) {
for (int i = 1; i <= n; ++i) {
if (!use[a[i]]) use[a[i]] = i;
else if (!use[b[i]]) use[b[i]] = i + n;
else return tar[0] = i, void();
}
}
tar[0] = 1;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("qoj4934.in", "r", stdin);
freopen("qoj4934.out", "w", stdout);
fprintf(stderr, "%.3lfMB\n", (&Mst - &Med) / 1048576.0);
#endif
read(n), read(m);
for (int i = 1; i <= n; ++i) read(a[i]), read(b[i]);
solve();
for (int i = 1; i <= n; ++i) tar[i+n] = i;
for (int i = n; i; --i) tar[i] = use[b[i]] > i ? tar[use[b[i]]] : i;
for (int i = 1; i <= m; ++i) ++cnt[tar[use[i]]];
for (int i = 1; i <= n; ++i) printf("%d\n", cnt[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1504kb
input:
3 6 1 2 2 4 4 2
output:
3 0 3
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 3540kb
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: 3552kb
input:
1 2 1 2
output:
2
result:
ok single line: '2'
Test #4:
score: -100
Wrong Answer
time: 4ms
memory: 3828kb
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'