QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#282260#1173. Knowledge Is...Aurora_WindWA 1ms5896kbC++14793b2023-12-11 17:00:522023-12-11 17:00:53

Judging History

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

  • [2023-12-11 17:00:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5896kb
  • [2023-12-11 17:00:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,m,j=1,p=1,l,r,mid,res,ans[500005],cnt;
struct node{int l,r,id;}a[500005],b[500005];
inline bool cmp1(node a,node b){return a.r<b.r;}
inline bool cmp2(node a,node b){return a.l<b.l;}
inline bool check(int x)
{
	for(int i=1;i<=x;++i) if(a[i].r>=b[n-x+i].l) return false;
	return true;
}
int main()
{
	scanf("%d%d",&n,&m),l=1,r=n/2;
	for(int i=1;i<=n;++i) scanf("%d%d",&a[i].l,&a[i].r),a[i].id=i,b[i]=a[i];
	sort(a+1,a+n+1,cmp1),sort(b+1,b+n+1,cmp2);
	while(l<=r)
	{
		mid=l+r>>1;
		if(check(mid)) l=mid+1,res=mid;
		else r=mid-1;
	}
	for(int i=1;i<=res;++i)
	{
		ans[a[i].id]=ans[b[n-res+i].id]=++cnt;
	}
	for(int i=1;i<=n;++i)
	{
		if(!ans[i]) ans[i]=++cnt;
		printf("%d ",(ans[i]<=m)?ans[i]:0);
	}
	return 0;
}

詳細信息

Test #1:

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

input:

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

output:

2 4 1 3 2 1 3 

result:

ok answer = 7

Test #2:

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

input:

2 2
1 2
3 4

output:

1 1 

result:

ok answer = 2

Test #3:

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

input:

2 1
1 2
2 3

output:

1 0 

result:

ok answer = 1

Test #4:

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

input:

1 1
4 26

output:

1 

result:

ok answer = 1

Test #5:

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

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:

83 119 120 121 32 31 122 27 123 124 125 18 25 24 93 126 127 128 20 53 96 51 129 130 131 132 133 134 135 136 38 91 137 138 13 77 139 140 85 84 141 142 143 89 15 144 16 80 145 79 4 3 103 115 146 93 147 148 1 7 149 150 96 151 152 110 153 154 155 156 106 157 106 158 159 102 109 160 161 111 112 162 28 33...

result:

ok answer = 376

Test #6:

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

input:

500 242
8 9
9 10
2 9
8 10
9 10
6 10
4 8
4 5
2 6
7 10
3 8
1 8
1 6
5 9
7 8
8 10
8 9
8 10
2 9
2 3
6 8
3 10
5 9
1 3
6 8
4 10
9 10
8 9
8 10
1 9
3 9
3 7
2 3
6 10
3 6
6 10
3 4
3 6
9 10
5 7
8 10
6 10
5 6
5 7
7 8
1 3
4 7
9 10
4 9
2 4
8 9
1 3
8 10
3 4
9 10
4 9
5 10
8 9
1 3
1 5
8 10
3 4
8 9
3 9
3 6
3 10
6 7
7 ...

output:

136 170 230 122 172 17 214 69 77 91 229 227 108 231 172 126 131 160 232 15 195 233 234 12 175 235 207 115 125 236 237 158 7 13 88 11 22 89 210 129 107 4 101 128 168 13 147 214 238 29 159 17 124 31 203 239 240 164 19 68 163 28 156 241 92 242 155 225 0 222 99 96 0 90 146 226 224 223 144 0 222 221 229 ...

result:

wrong answer participant answer = 437, judge answer = 471