QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#515734#4883. Bayan TestingwangjunruiWA 1ms6772kbC++141.1kb2024-08-11 22:26:182024-08-11 22:26:18

Judging History

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

  • [2024-08-11 22:26:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6772kb
  • [2024-08-11 22:26:18]
  • 提交

answer

#include <bits/stdc++.h>
template <typename T>
inline void ckmin(T &x, int y)
{
	if (x > y)
		x = y;
}
template <typename T>
inline void ckmax(T &x, int y)
{
	if (x < y)
		x = y;
}
typedef long long ll;
using namespace std;
constexpr int N = 2e5 + 5;
int n, m;
struct node
{
	node(int _l = 0, int _r = 0) : l(_l), r(_r) {}
	int l, r;
	inline bool operator < (const node &rhs) const
	{
		return r != rhs.r ? r < rhs.r : l > rhs.l;
	}
} p[N * 2];
int a[N];
inline void work()
{
	int tot = 0;
	cin >> n >> m;
	for (int i = 1; i <= 2 * m; ++i)
	{
		int l, r;
		cin >> l >> r;
		if (l == r)
			continue;
		p[++tot] = node(l, r);
	}
	sort(p + 1, p + 1 + tot);
	if (tot < m)
	{
		cout << -1 << endl;
		return;
	}
	for (int i = 1; i <= p[tot - m].r; ++i)
		a[i] = i;
	if (p[tot - m].r == p[tot - m + 1].r)
		a[p[tot - m + 1].l] = p[tot - m].r;
	for (int i = p[tot - m].r + 1; i <= n; ++i)
		a[i] = 1e9;
	for (int i = 1; i <= n; ++i)
		cout << a[i] << ' ';
	cout << endl;
}
signed main()
{
	cin.tie(0), cout.tie(0);
	ios::sync_with_stdio(false);
	int T;
	cin >> T;
	while (T--)
		work();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 6772kb

input:

3
2 1
1 1
2 2
6 2
1 3
4 6
2 4
3 5
4 3
1 2
1 1
2 2
2 3
3 3
3 4

output:

-1
1 2 3 4 1000000000 1000000000 
1000000000 1000000000 1000000000 1000000000 

result:

wrong answer the number of segments with two equal elements is 1 != 2 (test case 2)