結果

問題 No.2160 みたりのDominator
ユーザー 华恋~韵华恋~韵
提出日時 2024-04-14 10:38:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 3,698 bytes
コンパイル時間 1,120 ms
コンパイル使用メモリ 94,480 KB
実行使用メモリ 34,460 KB
最終ジャッジ日時 2024-04-14 10:38:48
合計ジャッジ時間 7,430 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
19,932 KB
testcase_01 AC 9 ms
23,268 KB
testcase_02 AC 5 ms
20,052 KB
testcase_03 AC 6 ms
26,060 KB
testcase_04 AC 6 ms
24,140 KB
testcase_05 AC 7 ms
26,188 KB
testcase_06 AC 6 ms
26,056 KB
testcase_07 AC 5 ms
22,100 KB
testcase_08 AC 5 ms
19,928 KB
testcase_09 AC 5 ms
20,056 KB
testcase_10 AC 5 ms
20,052 KB
testcase_11 AC 6 ms
19,928 KB
testcase_12 AC 5 ms
20,056 KB
testcase_13 AC 5 ms
19,924 KB
testcase_14 AC 5 ms
20,052 KB
testcase_15 AC 5 ms
19,924 KB
testcase_16 AC 5 ms
20,056 KB
testcase_17 AC 5 ms
20,052 KB
testcase_18 AC 5 ms
20,052 KB
testcase_19 AC 6 ms
19,924 KB
testcase_20 AC 5 ms
20,056 KB
testcase_21 AC 5 ms
20,056 KB
testcase_22 AC 5 ms
20,056 KB
testcase_23 AC 6 ms
24,016 KB
testcase_24 AC 6 ms
26,064 KB
testcase_25 AC 6 ms
26,184 KB
testcase_26 AC 6 ms
26,056 KB
testcase_27 AC 6 ms
26,060 KB
testcase_28 AC 6 ms
26,188 KB
testcase_29 AC 7 ms
26,188 KB
testcase_30 AC 6 ms
26,188 KB
testcase_31 AC 7 ms
26,188 KB
testcase_32 AC 6 ms
26,188 KB
testcase_33 AC 5 ms
17,880 KB
testcase_34 AC 9 ms
22,352 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 5 ms
20,056 KB
testcase_37 AC 6 ms
26,192 KB
testcase_38 AC 6 ms
24,016 KB
testcase_39 AC 6 ms
24,020 KB
testcase_40 AC 16 ms
21,412 KB
testcase_41 AC 15 ms
21,272 KB
testcase_42 AC 11 ms
22,996 KB
testcase_43 AC 14 ms
21,272 KB
testcase_44 AC 16 ms
23,292 KB
testcase_45 AC 17 ms
21,276 KB
testcase_46 AC 15 ms
23,376 KB
testcase_47 AC 11 ms
20,824 KB
testcase_48 AC 14 ms
22,968 KB
testcase_49 AC 16 ms
25,484 KB
testcase_50 AC 15 ms
23,584 KB
testcase_51 AC 11 ms
21,032 KB
testcase_52 AC 15 ms
25,252 KB
testcase_53 AC 15 ms
21,364 KB
testcase_54 AC 12 ms
24,920 KB
testcase_55 AC 50 ms
30,536 KB
testcase_56 AC 46 ms
32,636 KB
testcase_57 AC 48 ms
28,744 KB
testcase_58 AC 51 ms
32,448 KB
testcase_59 AC 49 ms
28,364 KB
testcase_60 AC 49 ms
30,468 KB
testcase_61 AC 48 ms
32,336 KB
testcase_62 AC 50 ms
30,732 KB
testcase_63 AC 50 ms
32,600 KB
testcase_64 AC 48 ms
28,496 KB
testcase_65 AC 23 ms
30,540 KB
testcase_66 AC 27 ms
28,364 KB
testcase_67 AC 26 ms
28,108 KB
testcase_68 AC 45 ms
34,460 KB
testcase_69 AC 36 ms
32,700 KB
testcase_70 AC 47 ms
32,460 KB
testcase_71 AC 17 ms
26,576 KB
testcase_72 AC 30 ms
34,380 KB
testcase_73 AC 49 ms
30,416 KB
testcase_74 AC 50 ms
30,284 KB
testcase_75 AC 8 ms
28,276 KB
testcase_76 AC 8 ms
26,188 KB
testcase_77 AC 23 ms
32,332 KB
testcase_78 AC 27 ms
32,460 KB
testcase_79 AC 8 ms
26,316 KB
testcase_80 AC 8 ms
26,316 KB
testcase_81 AC 9 ms
26,448 KB
testcase_82 AC 11 ms
32,584 KB
testcase_83 AC 14 ms
25,024 KB
61_evil_bias_nocross_01.txt AC 16 ms
25,612 KB
61_evil_bias_nocross_02.txt AC 14 ms
25,460 KB
61_evil_bias_nocross_03.txt AC 9 ms
20,700 KB
61_evil_bias_nocross_04.txt AC 13 ms
25,240 KB
61_evil_bias_nocross_05.txt AC 14 ms
25,568 KB
61_evil_bias_nocross_06.txt AC 14 ms
21,412 KB
61_evil_bias_nocross_07.txt AC 11 ms
20,652 KB
61_evil_bias_nocross_08.txt AC 14 ms
23,232 KB
61_evil_bias_nocross_09.txt AC 13 ms
23,408 KB
61_evil_bias_nocross_10.txt AC 10 ms
22,840 KB
61_evil_bias_nocross_11.txt AC 11 ms
21,112 KB
61_evil_bias_nocross_12.txt AC 14 ms
23,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<random>
#include<array>
#include<assert.h>
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n'
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n'
#define DE(fmt,...) fprintf(stderr, "Line %d : " fmt "\n",__LINE__,##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<ll,int>pli;
typedef pair<ll,ll>pll;
typedef pair<int,ll>pil;
typedef vector<int>vi;
typedef vector<ll>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
template<typename T>T cmax(T &x, T y){return x=x>y?x:y;}
template<typename T>T cmin(T &x, T y){return x=x<y?x:y;}
template<typename T>
T &read(T &r){
	r=0;bool w=0;char ch=getchar();
	while(ch<'0'||ch>'9')w=ch=='-'?1:0,ch=getchar();
	while(ch>='0'&&ch<='9')r=r*10+(ch^48),ch=getchar();
	return r=w?-r:r;
}
template<typename T1,typename... T2>
void read(T1 &x,T2& ...y){read(x);read(y...);}
const int N=8000010;
int n1,n2,n3,m,S,T;
array<int,2>eg[N];
void solve(int *s,int l,int r){
	auto pos=[&](int x){
		if(x==S)return 0;
		if(x==T)return r-l+2;
		if(x>=l&&x<=r)
			return x-l+1;
		return -1;
	};
	for(int i=1;i<=m;i++){
		int u=eg[i][0],v=eg[i][1];
		u=pos(u);v=pos(v);
		if(u!=-1&&v!=-1){
			if(u>v)swap(u,v);
			s[u+1]++;s[v+1]--;
		}
	}
	for(int i=1;i<=r-l+2;i++)s[i]+=s[i-1];
	for(int i=1;i<=r-l+2;i++)s[i]=(s[i]>0)?0:1;
	for(int i=1;i<=r-l+2;i++)s[i]+=s[i-1];
}
int s1[N],s2[N],s3[N];
int pre12[N],suf12[N];
int pre13[N],suf13[N];
int pre23[N],suf23[N];
int pre32[N],suf32[N];
void solve(int *pre,int *suf,int l1,int r1,int l2,int r2){
	for(int i=1;i<=r1-l1+2;i++)suf[i]=r2-l2+2,pre[i]=1;
	for(int i=1;i<=m;i++){
		int u=eg[i][0],v=eg[i][1];
		if(v>=l1&&v<=r1)swap(u,v);
		if(u>=l1&&u<=r1&&v>=l2&&v<=r2){
			u=u-l1+1;v=v-l2+1;
			cmin(suf[u],v);
			cmax(pre[u+1],v+1);
		}
	}
	for(int i=2;i<=r1-l1+2;i++)cmax(pre[i],pre[i-1]);
	for(int i=r1-l1+1;i>=1;i--)cmin(suf[i],suf[i+1]);
}
void init(){
	int l1=1,r1=n1;
	int l2=n1+1,r2=n1+n2;
	int l3=n1+n2+1,r3=n1+n2+n3;
	solve(s1,l1,r1);
	solve(s2,l2,r2);
	solve(s3,l3,r3);
	solve(pre12,suf12,l1,r1,l2,r2);
	solve(pre13,suf13,l1,r1,l3,r3);
	solve(pre23,suf23,l2,r2,l3,r3);
	solve(pre32,suf32,l3,r3,l2,r2);
	int L2=1,R2=0;
	int L3=1,R3=0;
	ll ans=0,sum=0;
	auto ins2=[&](int x){
		if(x>=L2&&s2[x]-s2[x-1]){
			int l=max(L3,pre23[x]),r=min(R3,suf23[x]);
			if(l<=r)
				sum+=s3[r]-s3[l-1];
		}
	};
	auto del2=[&](int x){
		if(x<=R2&&s2[x]-s2[x-1]){
			int l=max(L3,pre23[x]),r=min(R3,suf23[x]);
			if(l<=r)
				sum-=s3[r]-s3[l-1];
		}
	};
	auto ins3=[&](int x){
		if(x>=L3&&s3[x]-s3[x-1]){
			int l=max(L2,pre32[x]),r=min(R2,suf32[x]);
			if(l<=r)
				sum+=s2[r]-s2[l-1];
		}
	};
	auto del3=[&](int x){
		if(x<=R3&&s3[x]-s3[x-1]){
			int l=max(L2,pre32[x]),r=min(R2,suf32[x]);
			if(l<=r)
				sum-=s2[r]-s2[l-1];
		}
	};
	for(int o=1;o<=n1+1;o++)if(s1[o]-s1[o-1]){
		while(R2<suf12[o])++R2,ins2(R2);
		while(L2<pre12[o])del2(L2),++L2;
		while(R3<suf13[o])++R3,ins3(R3);
		while(L3<pre13[o])del3(L3),++L3;
		ans+=sum;
	}
	cout<<ans<<'\n';
}
signed main(){
//	#ifdef do_while_true
//		assert(freopen("night.in","r",stdin));
//		assert(freopen("night.out","w",stdout));
//	#endif
	read(n1,n2,n3,m);S=n1+n2+n3+1,T=S+1;
	for(int i=1,u,v;i<=m;i++){
		read(u,v);
		if(u>v)swap(u,v);
		eg[i]={u,v};
		if(u==S&&v==T){
			puts("0");
			return 0;
		}
	}
	init();
    #ifdef do_while_true
//		cerr<<'\n'<<"Time:"<<1.0*clock()/CLOCKS_PER_SEC*1000<<" ms"<<'\n';
	#endif
	return 0;
}
0