QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#282213#1173. Knowledge Is...zhichengWA 1ms3576kbC++14936b2023-12-11 16:28:312023-12-11 16:28:31

Judging History

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

  • [2023-12-11 16:28:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3576kb
  • [2023-12-11 16:28:31]
  • 提交

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++){
		ff[p[i].id]=f[i];
	}
	for(int i=1;i<=n;i++){
		if(cnt+1>m){
			printf("0 ");
			continue;
		}
		printf("%d ",ff[i]?0:++cnt);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3576kb

input:

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

output:

0 4 0 0 0 0 0 

result:

wrong answer participant answer = 1, judge answer = 7