QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#76499 | #5470. Hasty Santa Claus | XKError | WA | 1ms | 3684kb | C++ | 739b | 2023-02-10 08:49:59 | 2023-02-10 08:50:00 |
Judging History
answer
#include <bits/stdc++.h>
#define maxn 100005
using namespace std;
int fa[maxn];
int find(int x) {
return fa[x] == x ? x : (fa[x] = find(fa[x]));
}
void merge(int x, int y){
fa[find(x)] = find(y);
}
int n, k;
int t[maxn];
struct node{
int l, r, id;
};
node a[maxn];
int ans[maxn];
int main() {
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; i++) {
scanf("%d%d", &a[i].l, &a[i].r);
a[i].id = i;
}
for (int i = 1; i <= 50; i++) fa[i] = i;
sort(a + 1, a + n + 1, [&](node a, node b) {return a.r < b.r;});
for (int i = 1; i <= n; i++) {
int tmp = (ans[a[i].id] = find(a[i].l));
if (++t[tmp] == k) merge(tmp, tmp + 1);
}
for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3684kb
input:
5 1 23 25 23 27 24 25 25 25 25 26
output:
23 27 24 25 26
result:
wrong answer output line is not a valid date.(line = 23 27 24 25 26)