QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#570457#9310. Permutation Counting 4Retr00WA 0ms3792kbC++20559b2024-09-17 15:55:552024-09-17 15:55:56

Judging History

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

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

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;
		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 = find(u - 1), v = find(v);
			if (u == v)
				break;
			fa[u] = v;
		}
		cout << ((u == v) ? 0 : 1) << "\n";
	};

	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3792kb

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
1
1
1

result:

wrong answer 3rd words differ - expected: '0', found: '1'