QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#565174 | #9310. Permutation Counting 4 | red_jiu | WA | 0ms | 5640kb | C++17 | 897b | 2024-09-15 20:30:11 | 2024-09-15 20:30:11 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6 + 10;
const int MOD = 998244353;
typedef pair<ll, ll> PLL;
typedef pair<int, int > PII;
typedef pair<double, double> PDD;
ll n, zu[N];
pair<ll, ll>s[N];
ll find(ll x) { return x == zu[x] ? x : zu[x] = find(zu[x]); }
void solve(){
cin >> n;
for (int i = 1; i <= n + 1; i++)
zu[i] = i;
for (int i = 1; i <= n; i++)
{
cin >> s[i].first >> s[i].second;
//s[i].second++;
}
for (int i = 1; i <= n; i++)
{
ll x = find(s[i].first), y = find(s[i].second);
if (x == y)
{
cout << "0\n";
return;
}
zu[x] = y;
}
cout << "1\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int T = 1;
cin >> T;
while (T--){
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 5640kb
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'