QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#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;
}
詳細信息
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)