QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#76499#5470. Hasty Santa ClausXKErrorWA 1ms3684kbC++739b2023-02-10 08:49:592023-02-10 08:50:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-10 08:50:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3684kb
  • [2023-02-10 08:49:59]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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)