QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574318#9310. Permutation Counting 4XyeeChengWA 0ms3804kbC++23989b2024-09-18 21:31:482024-09-18 21:31:50

Judging History

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

  • [2024-09-18 21:31:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3804kb
  • [2024-09-18 21:31:48]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define rep(i, a, n) for (int i = a; i <= n; i++)
#define per(i, a, n) for (int i = n; i >= a; i--)
#define all(x) (x).begin(), (x).end()
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;

void solve()
{
	int n;
	cin >> n;
	vector<vector<int>> a(n + 1);
	vector<int> vis(n + 1, 0);
	rep (i, 1, n)
	{
		int l, r;
		cin >> l >> r;
		a[l].push_back(r);
	}
	rep (i, 1, n)
	{
		sort(all(a[i]));
	}
	rep (i, 1, n)
	{
		int last = i - 1;
		for (auto x: a[i])
		{
			vis[last + 1]++;
			if (vis[last + 1] % 2)
			{
				cout << 0 << endl;
				return;
			}
			last = x;
		}
	}
	rep (i, 1, n) if (vis[i] == 0)
		{
			cout << 0 << endl;
			return;
		}
	cout << 1 << endl;
}

signed main()
{
	IOS;
	int t = 1;
	cin >> t;
	while (t--) solve();
	return 0;
}

詳細信息

Test #1:

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

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'