QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#99203#6308. Magicice_cupRE 2ms3516kbC++14713b2023-04-21 16:55:282023-04-21 16:55:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-21 16:55:32]
  • 评测
  • 测评结果:RE
  • 用时:2ms
  • 内存:3516kb
  • [2023-04-21 16:55:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int head[10010],cnt,n,ask[10010],mt[10010];
bitset<5010>g[5010];
struct node{
	int l,r;
}a[5010];
bool fi(int u){
	for(auto v=g[u]._Find_first();v<=n;v=g[u]._Find_next(v)){
		if(ask[v])continue;
		ask[v]=1;
		if(!mt[v]||fi(mt[v])){
			mt[v]=u;
			mt[u]=v;
			return 1;
		}
	}
	return 0;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i].l>>a[i].r;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(i==j)continue;
			if(a[i].l<a[j].l&&a[j].l<a[i].r&&a[i].r<a[j].r){
				g[j][i]=1;
			}
		}
	}
	int num=2*n;
	for(int i=1;i<=2*n;i++){
		if(mt[i])continue;
		memset(ask,0,sizeof(ask));
		num-=fi(i);
	}
	cout<<num;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3516kb

input:

5
2 3
6 7
1 9
5 10
4 8

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: -100
Runtime Error

input:

5000
7985 7987
42 46
1591 1593
407 410
6305 6306
1456 1457
5874 5875
7135 7137
7041 7046
6813 6815
8868 8871
665 666
4055 4056
9789 9796
7067 7068
4745 4746
5167 5171
1735 1737
2125 2128
1444 1447
1348 1352
6087 6090
1381 1384
1600 1601
5187 5190
2801 2802
8449 8450
9376 9377
4021 4024
2674 2676
490...

output:


result: