QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#570349 | #9310. Permutation Counting 4 | Retr00 | WA | 0ms | 3624kb | C++20 | 562b | 2024-09-17 15:25:25 | 2024-09-17 15:25:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
int n, u, v, flg = 1;
cin >> n;
vector<int> fa(n + 1);
iota(fa.begin(), fa.end(), 0);
function<int(int)> find = [&](int x)
{
return fa[x] = (fa[x] == x ? x : find(fa[x]));
};
for (int i = 0; i < n; i++)
{
cin >> u >> v;
u--;
u = find(u), v = find(v);
flg = (find(u) != find(v));
fa[u] = v;
}
cout << flg << "\n";
};
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3624kb
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:
1 1 1 1
result:
wrong answer 1st words differ - expected: '0', found: '1'