QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#567231 | #9310. Permutation Counting 4 | Lnian | WA | 0ms | 11144kb | C++20 | 1.1kb | 2024-09-16 10:17:10 | 2024-09-16 10:17:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using i128 = __int128;
using ull = unsigned long long;
#define pll pair<ll, ll>
#define pii pair<int, int>
#define vi vector<int>
#define fir(i, a, b) for (int i = a; i <= b; i++)
#define pqi priority_queue<int> // 优先队列
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
const int N = 1e6 + 10;
vector<int> f(N);
int find(int x)
{
return f[x] == x ? x : f[x] = find(f[x]);
}
void solve()
{
int n;
cin >> n;
for (int i = 0; i < n + 1; i++)
f[i] = i;
bool st = 1;
for (int i = 1; i < n + 1; i++)
{
int l, r;
cin >> l >> r;
if (find(l) == find(r))
st = 0;
else
f[find(l)] = find(r);
}
cout << st << "\n";
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 11144kb
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'