QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#468650 | #8730. Particija | PorNPtree | 0 | 0ms | 14748kb | C++17 | 981b | 2024-07-08 22:01:12 | 2024-07-08 22:01:13 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, a[N], b[N], vis[N << 1], c[2];
vector<int> G[N << 1];
void dfs(int x) {
++c[vis[x]];
for (auto v : G[x]) if (!~vis[v]) vis[v] = !vis[x], dfs(v);
}
signed main() {
int T, opt; scanf("%d%d", &T, &opt);
while (T--) {
scanf("%d", &n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
for (int i = 1; i <= n; ++i) scanf("%d", &b[i]);
if (opt == 0) {
for (int i = 1; i <= n << 1; ++i) G[i].clear(), vis[i] = -1;
for (int i = 1; i <= n; ++i) {
G[a[i]].push_back(b[i] + n), G[b[i] + n].push_back(a[i]);
}
int res = 0;
for (int i = 1; i <= n << 1; ++i) if (!~vis[i << 1]) {
c[0] = c[1] = 0, vis[i] = 0, dfs(i), res += min(c[0], c[1]);
}
printf("%d\n", res);
continue;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 14748kb
input:
751 0 5 5 5 5 5 5 1 2 3 4 5 6 1 2 2 6 4 5 3 6 3 4 3 3 8 5 8 6 5 4 3 6 6 3 4 4 3 2 6 6 2 5 1 1 1 1 1 5 5 4 3 3 8 5 7 3 7 8 2 7 5 4 2 6 3 6 2 5 6 8 5 8 7 3 4 6 5 2 3 3 3 3 3 3 1 3 6 2 1 3 1 3 6 5 5 3 6 3 5 8 8 6 2 4 7 7 4 1 7 7 3 3 7 7 3 3 5 2 1 4 4 2 1 2 1 4 1 6 2 2 2 2 2 2 5 3 2 1 4 6 7 4 1 7 4 2 3 ...
output:
1 2 3 1 4 2 2 2 3 1 3 1 1 4 3 4 3 2 3 4 3 1 3 3 1 2 3 1 1 3 4 2 1 2 4 3 3 4 3 2 1 1 2 3 2 1 3 3 4 3 2 2 3 1 1 3 2 2 3 2 3 1 3 3 3 4 3 2 1 3 1 1 1 4 3 2 3 1 2 1 2 1 3 2 1 2 2 2 3 1 2 1 2 3 1 3 2 3 2 4 4 1 2 3 3 3 2 2 3 1 3 3 3 3 3 1 3 4 2 2 4 2 3 1 3 1 1 1 1 1 3 4 2 2 3 1 1 3 3 2 2 3 2 4 3 5 3 1 3 4 ...
result:
wrong answer 2nd numbers differ - expected: '3', found: '2'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #14:
score: 0
Wrong Answer
time: 0ms
memory: 14292kb
input:
719 1 8 1 1 2 1 5 1 5 1 2 5 6 1 4 4 8 7 5 5 5 5 5 5 1 4 1 2 5 8 5 2 4 7 8 6 1 3 4 4 4 4 4 4 4 4 7 4 5 5 4 4 5 5 1 7 5 3 6 2 4 5 1 4 4 5 2 1 4 2 1 3 2 1 2 2 1 8 6 8 6 2 8 4 5 6 3 4 7 4 8 8 8 4 8 2 7 2 7 2 2 2 2 3 4 1 3 8 5 7 4 8 3 3 2 8 5 6 4 4 4 7 7 4 7 7 8 7 5 2 4 4 4 4 5 2 3 1 4 6 1 1 1 1 1 1 6 5 ...
output:
result:
wrong answer Answer contains longer sequence [length = 719], but output contains 0 elements
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Wrong Answer
Test #40:
score: 0
Wrong Answer
time: 0ms
memory: 14652kb
input:
704 2 6 5 3 1 4 4 4 4 5 6 4 5 2 7 1 4 1 4 1 1 1 7 1 4 1 6 7 5 7 5 6 6 5 5 6 6 3 4 6 1 7 3 5 8 8 2 7 4 6 1 3 4 6 6 6 6 6 6 6 6 8 1 3 1 2 8 7 4 1 8 8 8 8 5 1 8 8 8 1 6 2 6 7 3 5 8 7 7 5 8 5 7 5 5 6 6 4 5 3 6 1 3 3 3 3 4 3 7 3 3 7 3 3 3 3 1 4 5 3 6 5 7 5 3 1 5 5 1 5 4 3 5 3 6 4 1 4 2 2 2 6 2 2 1 5 2 6 ...
output:
result:
wrong answer Answer contains longer sequence [length = 704], but output contains 0 elements
Subtask #6:
score: 0
Skipped
Dependency #5:
0%