QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#567231#9310. Permutation Counting 4LnianWA 0ms11144kbC++201.1kb2024-09-16 10:17:102024-09-16 10:17:10

Judging History

你现在查看的是最新测评结果

  • [2024-09-18 14:56:40]
  • hack成功,自动添加数据
  • (/hack/835)
  • [2024-09-18 14:41:06]
  • hack成功,自动添加数据
  • (/hack/831)
  • [2024-09-17 12:14:52]
  • hack成功,自动添加数据
  • (/hack/825)
  • [2024-09-16 10:17:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:11144kb
  • [2024-09-16 10:17:10]
  • 提交

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'