QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#515734 | #4883. Bayan Testing | wangjunrui | WA | 1ms | 6772kb | C++14 | 1.1kb | 2024-08-11 22:26:18 | 2024-08-11 22:26:18 |
Judging History
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)