QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#567188 | #9310. Permutation Counting 4 | Luckyblock | WA | 0ms | 3692kb | C++20 | 917b | 2024-09-16 09:49:12 | 2024-09-16 09:49:13 |
Judging History
answer
//
/*
By:Luckyblock
*/
#include <bits/stdc++.h>
#define LL long long
const int kN = 1e6 + 10;
//=============================================================
int n, fa[kN];
//=============================================================
int find(int x_) {
return fa[x_] == x_ ? x_ : fa[x_] = find(fa[x_]);
}
void merge(int x_, int y_) {
int fx = find(x_), fy = find(y_);
if (fx == fy) return ;
fa[fx] = fy;
}
//=============================================================
int main() {
//freopen("1.txt", "r", stdin);
std::ios::sync_with_stdio(0), std::cin.tie(0);
int T; std::cin >> T;
while (T --) {
std::cin >> n;
for (int i = 0; i <= n; ++ i) fa[i] = i;
int ans = 1;
for (int i = 1; i <= n; ++ i) {
int l, r; std::cin >> l >> r;
if (find(l) == find(r)) ans = 0;
merge(l, r);
}
std::cout << ans << "\n";
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3692kb
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 0 0 0
result:
wrong answer 2nd words differ - expected: '1', found: '0'