QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#566682 | #9310. Permutation Counting 4 | Rapids | WA | 3ms | 7600kb | C++20 | 623b | 2024-09-16 01:11:04 | 2024-09-16 01:11:04 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
const int N = 1e6 + 10;
int p[N];
int find(int x) {
return x == p[x] ? x : p[x] = find(p[x]);
}
void solve() {
int n;
std::cin >> n;
for (int i = 0; i < N; i++) {
p[i] = i;
}
for (int i = 0; i < n; i++) {
int x, y;
std::cin >> x >> y;
x = find(x - 1), y = find(y);
if(x == y) {
std::cout << 0 << '\n';
return;
}
p[x] = y;
}
std::cout << 1 << '\n';
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(0), std::cout.tie(0);
int t;
std::cin >> t;
while (t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 7600kb
input:
4 5 1 2 1 5 1 2 1 2 2 2 5 1 1 2 4 2 3 5 5 3 4 5 3 5 1 2 3 4 3 5 3 3 5 1 5 1 4 4 5 5 5 1 2
output:
0 1 1 1
result:
wrong answer 3rd words differ - expected: '0', found: '1'