QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#155051#6308. Magic275307894aML 2ms3996kbC++141.1kb2023-09-01 08:19:102023-09-01 08:19:11

Judging History

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

  • [2023-09-01 08:19:11]
  • 评测
  • 测评结果:ML
  • 用时:2ms
  • 内存:3996kb
  • [2023-09-01 08:19:10]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__int128;
const int N=5e3+5,M=N*40+5,K=(1<<25)+5,mod=998244353,Mod=mod-1;const db eps=1e-9;const ll INF=1e18+7;mt19937 rnd(time(0));
int n,L[N],R[N];
bitset<N> A[N],vis;int mch[N];
int dfs(int x){
	vis[x]=1;
	for(int i=1;i<=n;i++) if(A[x][i]&&!vis[i]) {
		if(!mch[i]||dfs(mch[i])) {mch[i]=x;return 1;}
	}
	return 0;
}
void Solve(){
	int i,j;scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%d%d",&L[i],&R[i]);
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++) if(i^j&&L[j]<=L[i]&&L[i]<=R[j]&&R[j]<=R[i]) A[i][j]=1;
	}
	int Ct=2*n;
	for(i=1;i<=n;i++) if(vis.reset(),dfs(i)) Ct--;
	printf("%d\n",Ct);
}
int main(){
	int t;
	// scanf("%d",&t);
	t=1;
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
2 3
6 7
1 9
5 10
4 8

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: -100
Memory Limit Exceeded

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: