QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#282245#1173. Knowledge Is...HanghangWA 1ms7680kbC++14730b2023-12-11 16:45:422023-12-11 16:45:42

Judging History

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

  • [2023-12-11 16:45:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7680kb
  • [2023-12-11 16:45:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int N=1e6+3;
int n,m,ans[N];
bool v[N];
struct Nod{int l,r,id;}a[N],b[N];
bool CL(Nod a,Nod b){return a.l<b.l;}
bool CR(Nod a,Nod b){return a.r<b.r;}
bool Chk(int x)
{
	for(int i=1;i<=x;i++)if(a[i].r>=b[n-x+i].l)return 0;
	return 1;
}
int main()
{
	cin>>n>>m;int l=0,r=n/2;
	for(int i=1;i<=n;i++)cin>>a[i].l>>a[i].r,a[i].id=i,b[i]=a[i];
	sort(a+1,a+n+1,CR);sort(b+1,b+n+1,CL);
	while(l<r)
	{
		int mi=(l+r)/2+1;
		Chk(mi)?l=mi:r=mi-1; 
	}
	for(int i=1;i<=min(m,l);i++)
	    ans[a[i].id]=ans[b[n-l+i].id]=i,v[a[i].id]=v[b[n-l+i].id]=1;
	//for(int i=1;i<=n&&l<m;i++)if(!v[i])ans[i]=++l;
	for(int i=1;i<=n;i++)cout<<ans[i]<<" ";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2 0 1 3 2 1 3 

result:

wrong answer participant answer = 6, judge answer = 7