結果

問題 No.2160 みたりのDominator
ユーザー 华恋~韵华恋~韵
提出日時 2024-04-14 10:55:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 2,453 bytes
コンパイル時間 1,988 ms
コンパイル使用メモリ 168,240 KB
実行使用メモリ 55,632 KB
最終ジャッジ日時 2024-04-14 10:56:02
合計ジャッジ時間 12,505 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
29,168 KB
testcase_01 AC 11 ms
55,632 KB
testcase_02 AC 6 ms
29,040 KB
testcase_03 AC 7 ms
26,188 KB
testcase_04 AC 6 ms
26,436 KB
testcase_05 AC 6 ms
26,312 KB
testcase_06 AC 6 ms
26,184 KB
testcase_07 AC 6 ms
24,136 KB
testcase_08 AC 6 ms
22,356 KB
testcase_09 AC 6 ms
22,096 KB
testcase_10 AC 6 ms
22,096 KB
testcase_11 AC 5 ms
22,096 KB
testcase_12 AC 5 ms
22,228 KB
testcase_13 AC 6 ms
22,224 KB
testcase_14 AC 5 ms
22,348 KB
testcase_15 AC 5 ms
22,356 KB
testcase_16 AC 6 ms
22,096 KB
testcase_17 AC 5 ms
22,224 KB
testcase_18 AC 5 ms
22,352 KB
testcase_19 AC 5 ms
22,092 KB
testcase_20 AC 5 ms
22,228 KB
testcase_21 AC 6 ms
22,100 KB
testcase_22 AC 5 ms
22,224 KB
testcase_23 AC 6 ms
26,440 KB
testcase_24 AC 6 ms
26,440 KB
testcase_25 AC 6 ms
26,180 KB
testcase_26 AC 7 ms
26,184 KB
testcase_27 AC 6 ms
26,444 KB
testcase_28 AC 6 ms
26,312 KB
testcase_29 AC 6 ms
26,184 KB
testcase_30 AC 6 ms
26,308 KB
testcase_31 AC 6 ms
26,184 KB
testcase_32 AC 6 ms
26,440 KB
testcase_33 AC 5 ms
22,084 KB
testcase_34 AC 12 ms
29,408 KB
testcase_35 AC 5 ms
19,908 KB
testcase_36 AC 6 ms
22,224 KB
testcase_37 AC 7 ms
26,312 KB
testcase_38 AC 6 ms
24,272 KB
testcase_39 AC 6 ms
24,272 KB
testcase_40 AC 14 ms
29,024 KB
testcase_41 AC 13 ms
28,960 KB
testcase_42 AC 11 ms
26,876 KB
testcase_43 AC 13 ms
27,000 KB
testcase_44 AC 14 ms
27,156 KB
testcase_45 AC 14 ms
29,220 KB
testcase_46 AC 14 ms
29,416 KB
testcase_47 AC 10 ms
26,624 KB
testcase_48 AC 11 ms
29,044 KB
testcase_49 AC 14 ms
31,120 KB
testcase_50 AC 12 ms
29,228 KB
testcase_51 AC 12 ms
24,760 KB
testcase_52 AC 16 ms
26,852 KB
testcase_53 AC 15 ms
29,332 KB
testcase_54 AC 22 ms
24,932 KB
testcase_55 AC 25 ms
32,460 KB
testcase_56 AC 24 ms
36,548 KB
testcase_57 AC 24 ms
34,500 KB
testcase_58 AC 28 ms
34,508 KB
testcase_59 AC 26 ms
34,504 KB
testcase_60 AC 25 ms
38,468 KB
testcase_61 AC 26 ms
36,552 KB
testcase_62 AC 30 ms
38,728 KB
testcase_63 AC 26 ms
34,628 KB
testcase_64 AC 24 ms
34,376 KB
testcase_65 AC 15 ms
30,280 KB
testcase_66 AC 16 ms
32,588 KB
testcase_67 AC 18 ms
30,536 KB
testcase_68 AC 29 ms
36,684 KB
testcase_69 AC 21 ms
36,420 KB
testcase_70 AC 29 ms
36,676 KB
testcase_71 AC 13 ms
28,232 KB
testcase_72 AC 21 ms
34,376 KB
testcase_73 AC 27 ms
32,584 KB
testcase_74 AC 27 ms
36,424 KB
testcase_75 AC 9 ms
30,280 KB
testcase_76 AC 8 ms
30,280 KB
testcase_77 AC 17 ms
30,280 KB
testcase_78 AC 19 ms
34,504 KB
testcase_79 AC 8 ms
28,228 KB
testcase_80 AC 8 ms
28,364 KB
testcase_81 AC 9 ms
30,412 KB
testcase_82 AC 11 ms
32,456 KB
testcase_83 AC 12 ms
32,784 KB
61_evil_bias_nocross_01.txt AC 14 ms
33,320 KB
61_evil_bias_nocross_02.txt AC 14 ms
28,964 KB
61_evil_bias_nocross_03.txt AC 10 ms
27,008 KB
61_evil_bias_nocross_04.txt TLE -
61_evil_bias_nocross_05.txt AC 12 ms
28,948 KB
61_evil_bias_nocross_06.txt AC 15 ms
26,924 KB
61_evil_bias_nocross_07.txt AC 20 ms
26,932 KB
61_evil_bias_nocross_08.txt AC 14 ms
29,036 KB
61_evil_bias_nocross_09.txt AC 15 ms
29,444 KB
61_evil_bias_nocross_10.txt TLE -
61_evil_bias_nocross_11.txt AC 10 ms
24,808 KB
61_evil_bias_nocross_12.txt AC 29 ms
53,156 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:33:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   33 |                 auto [a,b]=id(x);
      |                      ^
main.cpp:39:22: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   39 |                 auto [c,d]=id(y);//printf("?%d %d %d %d\n",a,b,c,d);
      |                      ^

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=8e6+5;
char buf[1<<23],*p1=buf,*p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin),p1==p2)?EOF:*p1++)
template<class rd>
void read(rd &x){
	char c=getchar();
	for(;c<48||c>57;c=getchar());
	for(x=0;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
}
int n1,n2,n3,m,S,T;
int s[3][N],ln[3],pr[3][N],su[3][N];
long long ans;
pair<int,int>id(int x){
	if(x<=n1)return {0,x};
	if(x<=n2+n1)return {1,x-n1};
	return {2,x-n1-n2};
}
struct node{
	int l,r,ct;
}a1[N],a2[N];
int main(){
	read(n1),read(n2),read(n3),read(m);
	S=n1+n2+n3+1,T=S+1;
	ln[0]=n1,ln[1]=n2,ln[2]=n3;
	for(int i=0;i<3;++i)for(int j=0;j<=T;++j)pr[i][j]=-1,su[i][j]=N;
	for(int i=1,x,y;i<=m;++i){
		read(x),read(y);
		if(x>y)swap(x,y);
		if(x==S)return puts("0"),0;
		auto [a,b]=id(x);
		if(y==S||y==T){
			if(y==S)++s[a][0],--s[a][b];
			else ++s[a][b];
			continue;
		}
		auto [c,d]=id(y);//printf("?%d %d %d %d\n",a,b,c,d);
		if(a==c){
			++s[a][b];
			--s[a][d];
			continue;
		}
		if(!a)pr[c-1][b]=max(pr[c-1][b],d),su[c-1][b]=min(su[c-1][b],d);
		else pr[2][b]=max(pr[2][b],d),su[2][b]=min(su[2][b],d);
	}
	for(int i=0;i<3;++i){
		for(int j=1;j<=T;++j)pr[i][j]=max(pr[i][j],pr[i][j-1]);
		for(int j=T-1;~j;--j)su[i][j]=min(su[i][j],su[i][j+1]);
	}
	for(int i=0;i<3;++i)for(int j=1;j<=ln[i];++j)s[i][j]+=s[i][j-1];
	for(int i=0,j;j=i,i<=ln[0];i=j+1){
		if(pr[0][i]>=su[0][i+1])continue;
		int l=pr[0][i],r=su[0][i+1]-1;
		while(j<ln[0]&&pr[0][j+1]==l)++j;
		l=max(0,l),r=min(ln[1],r);
		int c1=0,c2=0;//printf("!%d %d %d %d\n",i,j,l,r);
		for(int k=i;k<=j;++k){
			if(s[0][k]||pr[1][k]>=su[1][k+1])continue;
			int L=pr[1][k],R=su[1][k+1]-1;
			if(c1&&a1[c1].l==L)++a1[c1].ct;
			else a1[++c1]={L,R,1};
		}
		for(int k=l;k<=r;++k){
			if(s[1][k]||pr[2][k]>=su[2][k+1])continue;
			int L=pr[2][k],R=su[2][k+1]-1;
			if(c2&&a2[c2].l==L)++a2[c2].ct;
			else a2[++c2]={L,R,1};
		}
		if(!c1||!c2)continue;
		int o=max(0,max(a1[1].l,a2[1].l)),p1=1,p2=1;
		//for(int k=1;k<=p1;++k)printf("1 %d %d %d\n",a1[k].l,a1[k].r,a1[k].ct);
		//for(int k=1;k<=p2;++k)printf("2 %d %d %d\n",a2[k].l,a2[k].r,a2[k].ct);
		while(p1<=c1&&o>a1[p1].r)++p1;
		while(p2<=c2&&o>a2[p2].r)++p2;
		while(o<=ln[2]&&p1<=c1&&p2<=c2){
			if(!s[2][o]&&o>=a1[p1].l&&o>=a2[p2].l)ans+=1ll*a1[p1].ct*a2[p2].ct;
			if(o==a1[p1].r)++p1;
			if(o==a2[p2].r)++p2;
			++o;
		}//printf("%lld\n",ans);
	}
	printf("%lld\n",ans);
	return 0;
}
0