QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#106406#6308. MagicHzweiTL 116ms15832kbC++147.8kb2023-05-17 17:41:452023-05-17 17:41:48

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-17 17:41:48]
  • 评测
  • 测评结果:TL
  • 用时:116ms
  • 内存:15832kb
  • [2023-05-17 17:41:45]
  • 提交

answer

// Words are flowing out like endless rain into a paper cup,
// They slither while they pass, they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my opened mind,
// Possessing and caressing me.
// Jai guru de va om
// Nothing's gonna change my world,
// Nothing's gonna change my world,
//
// Nothing's gonna change my world,
// Nothing's gonna change my world,
//
// Images of broken light which dance before me like a million eyes,
// That call me on and on across the universe,
// Thoughts meander like a restless wind inside a letter box they
// Tumble blindly as they make their way
// Across the universe
// Jai guru de va om
// Nothing's gonna change my world,
// Nothing's gonna change my world,
//
// Nothing's gonna change my world,
// Nothing's gonna change my world,
//
// Sounds of laughter shades of earth are ringing
// Through my open views inciting and inviting me
// Limitless undying love which shines around me like a
// Million suns, it calls me on and on
// Across the universe
// Jai guru de va om
// Nothing's gonna change my world,
// Nothing's gonna change my world,
//
// Nothing's gonna change my world,
// Nothing's gonna change my world,
//
// Jai guru de va

#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC target("avx,avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("Ofast,fast-math")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
//#include<iostream>
//#include<string>
//#include<cmath>
//#include<cstdio>
//#include<cctype>
//#include<cstring>
//#include<iomanip>
//#include<cstdlib>
//#include<ctime>
//#include<set>
//#include<map>
//#include<utility>
//#include<queue>
//#include<vector>
//#include<stack>
//#include<sstream>
//#include<algorithm>
using namespace std;
/*=====================================================================*/
#define ll long long
//#define int ll
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pdd pair<double,double>
#define ull unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(s) (s).begin(),(s).end()
#define repd(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define forr(i,a,b,c) for(int i=(int)(a);i<=(int)(b);i+=(int)(c))
#define forn(i,p,n) for(int i=(int)(p);i<=(int)(n);++i)
#define ford(i,p,n) for(int i=(int)(n);i>=(int)(p);--i)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();++i)
#define INF 0x3f3f3f3f
#define PI acos(-1)
#define Endl(x) cout<<x<<endl;
#define Blank(x) cout<<x<<" ";
#define modcg(x) if(x>=mod)x-=mod;
#define modcl(x) if(x<0)x+=mod;
#define lowbit(x) x&(-x)
/*=====================================================================*/
string int_to_string(ll n)
{
	string s="";
	while(n)
	{
		ll now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
ll string_to_int(string s)
{
	ll n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
mt19937 GeN(chrono::system_clock::now().time_since_epoch().count());
int Rand(int l,int r)
{
	uniform_int_distribution<>RAND1(l,r);
	return RAND1(GeN);
}
struct Fastmod
{
	int mod,b;
	typedef __int128 lll;
	void init(int m)
	{
		mod=m;
		b=((lll)1<<64)/mod;
	}
	int operator()(ull a)
	{
		int q=((lll)a*b)>>64,r=a-q*mod;
		modcg(r);
		return r;
	}
}MOD;
int mul(int a,int b)
{
	return MOD(a*b);
}
/*======================================================================*/
const int dx[]={-1,0,1,0};
const int dy[]={0,-1,0,1};
const int month[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}};
//think twice,code once
//think once,debug forever
const int MAXN=1e4+10;
struct Flow
{
	int s,t;
	bitset<MAXN> v[MAXN];
	inline void add_edge(int x,int y)
	{
		v[x][y]=1;
	}
	int dist[MAXN];
	bool bfs()
	{
		forn(i,1,t)
		{
			dist[i]=-1;
		}
		dist[s]=0;
		queue<int> q;
		q.push(s);
		while(!q.empty())
		{
			int now=q.front();q.pop();
			for(int u=v[now]._Find_next(0);u!=v[now].size();u=v[now]._Find_next(u))
			{
				if(dist[u]==-1)
				{
					dist[u]=dist[now]+1;
					q.push(u);
				} 
			}
		}
//		cout<<t<<endl;
//		forn(i,1,t)
//		{
//			cout<<dist[i]<<" ";
//		}
//		cout<<endl; 
		return dist[t]!=-1;
	}
	int cur[MAXN];
	int dfs(int now,int flow)
	{
		if(now==t)
		{
			return flow;
		}
		int aint=flow;
//		cout<<cur[now]<<" "<<v[now]._Find_next(cur[now])<<endl;
//		cur[now]=v[now]._Find_next(cur[now]); 
		for(int u=v[now]._Find_next(0);u!=v[now].size();u=v[now]._Find_next(u))
		{
//			cout<<now<<" "<<u<<endl;
			if(dist[u]==dist[now]+1)
			{
				int del=dfs(u,1);
				if(del)
				{
					v[now][u]=0;
					v[u][now]=1;
					aint--;
				}
				if(aint==0)
				{
					break;
				}
			}
		}
//		cout<<now<<" "<<flow<<" "<<aint<<endl;
		return flow-aint;
	}
	int ans;
	void dinic()
	{
//		forn(i,1,t)
//		{
//			forn(j,1,t)
//			{
//				cout<<v[i][j]<<" ";
//			}
//			cout<<endl;
//		}
		ans=0;
		while(bfs())
		{
//			forn(i,1,t)
//			{
//				cur[i]=v[i]._Find_next(0);
//			}
			ans+=dfs(s,INF);
		}
	}
}F;
int n;
int l[MAXN],r[MAXN];
void solve()
{
	cin>>n;
	forn(i,1,n)
	{
		cin>>l[i]>>r[i];
	}
	F.s=(n+1)<<1;
	F.t=F.s+1;
	forn(i,1,n)
	{
		F.add_edge(F.s,i<<1);
		F.add_edge(i<<1|1,F.t);
		forn(j,1,n)
		{
			if(l[i]<l[j]&&l[j]<r[i]&&r[i]<r[j])
			{
//				cout<<i<<" "<<j<<endl;
				F.add_edge(i<<1,j<<1|1);
			}
		}
	}
	F.dinic();
//	cout<<F.ans<<endl;
	cout<<2*n-F.ans<<endl;
}
/*======================================================================*/
signed main()
{
    cin.tie(0);
    cout.tie(0);
	std::ios::sync_with_stdio(false);
//#define Hank2007
#ifdef Hank2007
	freopen("input.txt","r",stdin);
	freopen("output1.txt","w",stdout);
#endif
  	/*====================================================================*/
  	int TEST_CASE=1;
//	cin>>TEST_CASE;
  	while(TEST_CASE--)
  	{
  		solve();
  	}
  	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
2 3
6 7
1 9
5 10
4 8

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: 0
Accepted
time: 71ms
memory: 15828kb

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:

8134

result:

ok 1 number(s): "8134"

Test #3:

score: 0
Accepted
time: 83ms
memory: 15832kb

input:

5000
3171 3172
4062 4064
4647 4651
3670 3673
7112 7114
9714 9717
3781 3789
8422 8426
457 460
5450 5454
7113 7122
6313 6320
9969 9973
828 832
6878 6892
4476 4483
892 903
251 259
6304 6315
130 134
9206 9215
2679 2686
9090 9091
8222 8228
9374 9375
2985 2989
3397 3401
4916 4918
6819 6821
883 889
2516 25...

output:

7047

result:

ok 1 number(s): "7047"

Test #4:

score: 0
Accepted
time: 89ms
memory: 15720kb

input:

5000
7269 7286
1979 1990
4225 4241
7866 7872
2052 2067
1508 1514
2366 2370
3488 3493
8979 8987
302 306
6730 6732
7704 7705
5528 5544
7420 7425
4705 4712
593 601
6662 6668
5228 5257
2008 2013
548 562
7949 7950
1017 1020
1025 1028
6 11
4722 4736
9945 9950
8368 8379
6781 6787
4558 4566
400 404
858 864
...

output:

6191

result:

ok 1 number(s): "6191"

Test #5:

score: 0
Accepted
time: 116ms
memory: 15816kb

input:

5000
3005 3008
7811 7821
2832 2840
9812 9818
3947 3952
3629 3665
7443 7455
1473 1478
1467 1494
5499 5508
229 232
9477 9498
9500 9514
4769 4775
9488 9503
1514 1520
5101 5112
2455 2456
3558 3610
9072 9188
659 666
2286 2301
9735 9782
5959 5984
5823 5844
1827 1835
3658 3681
3494 3503
1016 1018
3418 3420...

output:

5636

result:

ok 1 number(s): "5636"

Test #6:

score: -100
Time Limit Exceeded

input:

5000
1017 1019
5731 5744
8592 8697
3414 3561
277 356
4421 4458
7969 7989
3733 3759
1975 1986
6895 6898
8580 8657
2320 2325
6494 6510
3574 3616
7721 7780
7756 7835
1744 1748
5085 5102
5428 5588
6823 6847
9348 9405
1969 2064
1152 1242
3676 3679
5569 5713
213 248
8277 8285
3739 3782
5582 5604
9076 9105...

output:


result: