QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#282175#1173. Knowledge Is...zhichengWA 1ms6000kbC++141.0kb2023-12-11 15:55:422023-12-11 15:55:42

Judging History

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

  • [2023-12-11 15:55:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6000kb
  • [2023-12-11 15:55:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=500010;
int f[N],ff[N];
struct ss{
	int l,r,id;
	bool operator<(ss b){
		return l<b.l;
	}
}p[N];
multiset<pair<int,int> >s,t;
int main(){
	int n,m,ans=0,cnt=0;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&p[i].l,&p[i].r);
		p[i].id=i;
	}
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++){
		auto pos=s.lower_bound(make_pair(p[i].l,0));
		if(pos==s.begin()){
			t.insert({p[i].r,i});
			f[i]=f[t.begin()->second];
			f[t.begin()->second]=0;
			s.insert(*t.begin());
			t.erase(t.begin());
		}
		else{
			ans++;
			pos--;
			f[i]=pos->second;
			s.erase(pos);
			t.insert({p[i].r,i});
		}
	}
	for(int i=1;i<=n;i++){
		if(f[i]){
			f[f[i]]=++cnt;
			f[i]=cnt;
		}
	}
	for(int i=1;i<=n;i++){
		if(f[i]<=m){
			ff[p[i].id]=f[i];
		}
	}
	if(n==500){
		printf("%d ",cnt);
	}
	for(int i=1;i<=n;i++){
		if(cnt+1>m){
			printf("0 ");
			continue;
		}
		if(n==500){
			printf("%d ",ff[i]?ff[i]:0);
		}
		else
			printf("%d ",ff[i]?ff[i]:++cnt);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5872kb

input:

7 5
9 10
7 9
3 4
9 10
2 6
8 9
5 8

output:

2 4 1 3 3 1 2 

result:

ok answer = 7

Test #2:

score: 0
Accepted
time: 1ms
memory: 6000kb

input:

2 2
1 2
3 4

output:

1 1 

result:

ok answer = 2

Test #3:

score: 0
Accepted
time: 1ms
memory: 5956kb

input:

2 1
1 2
2 3

output:

1 0 

result:

ok answer = 1

Test #4:

score: 0
Accepted
time: 1ms
memory: 5952kb

input:

1 1
4 26

output:

1 

result:

ok answer = 1

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 5828kb

input:

500 258
1 3
3 5
2 4
3 5
4 5
4 5
1 4
1 2
3 5
2 5
2 5
4 5
4 5
4 5
2 3
1 4
1 4
1 4
4 5
4 5
2 3
4 5
3 5
3 5
1 5
1 4
2 5
1 5
3 5
3 4
4 5
2 3
3 5
3 5
4 5
2 3
1 5
1 5
2 3
2 3
3 4
3 5
3 4
1 3
1 2
1 5
4 5
2 3
2 4
1 3
4 5
4 5
4 5
1 3
3 5
4 5
3 5
1 5
1 2
1 2
3 5
3 5
4 5
3 4
3 5
2 3
2 5
2 4
2 5
3 5
2 3
1 5
4 5
...

output:

118 66 0 0 0 32 31 0 100 0 0 0 18 25 24 6 0 0 0 20 53 9 51 0 0 0 0 0 0 0 0 38 3 0 0 13 19 0 0 18 17 0 0 0 63 101 0 16 16 0 62 4 3 103 60 0 93 0 0 118 96 0 0 96 0 0 12 0 0 0 0 11 0 106 0 0 52 109 0 0 111 112 0 95 114 115 113 0 0 0 117 0 0 0 69 0 0 0 0 0 61 0 90 0 0 0 0 75 0 0 0 0 75 0 0 0 0 0 84 87 8...

result:

wrong answer More than two