QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#573332#9313. Make MaxMaxDYFWA 0ms3640kbC++23732b2024-09-18 18:11:332024-09-18 18:11:41

Judging History

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

  • [2024-09-18 18:11:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3640kb
  • [2024-09-18 18:11:33]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
void work()
{
	int n;
	cin >> n;
	typedef pair<int, int> pii;
	priority_queue<pii, vector<pii>, greater<pii>> q;
	for (int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		q.push({x, y});
	}
	int lst_l = 0, lst_r = 0;
	while (!q.empty())
	{
		auto [x, y] = q.top();
		q.pop();
		if (x == lst_l)
		{
			if (y == lst_r)
			{
				cout << 0 << '\n';
				return;
			}
			q.push({lst_r + 1, y});
			continue;
		}
		if (lst_l + 1 != x)
		{
			cout << 0 << '\n';
			return;
		}
		lst_l = x;
		lst_r = y;
	}
	cout << (lst_l == n ? "1\n" : "0\n");
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	while (t--)
		work();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
2
1 2
2
2 2
7
1 1 1 2 2 2 2
3
1 2 3

output:

1
0
0
0

result:

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