結果

問題 No.1605 Matrix Shape
ユーザー tailstails
提出日時 2021-07-17 17:59:35
言語 cLay
(20231016-1)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 2,909 ms
コンパイル使用メモリ 170,784 KB
実行使用メモリ 9,052 KB
最終ジャッジ日時 2023-09-19 02:31:07
合計ジャッジ時間 6,907 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,616 KB
testcase_01 AC 3 ms
7,516 KB
testcase_02 AC 3 ms
7,468 KB
testcase_03 AC 3 ms
7,476 KB
testcase_04 AC 2 ms
7,476 KB
testcase_05 AC 3 ms
7,480 KB
testcase_06 AC 2 ms
7,492 KB
testcase_07 AC 3 ms
7,472 KB
testcase_08 AC 2 ms
7,460 KB
testcase_09 AC 3 ms
7,468 KB
testcase_10 AC 3 ms
7,448 KB
testcase_11 AC 2 ms
7,448 KB
testcase_12 AC 3 ms
7,468 KB
testcase_13 AC 2 ms
7,540 KB
testcase_14 AC 3 ms
7,460 KB
testcase_15 AC 3 ms
7,472 KB
testcase_16 AC 3 ms
7,456 KB
testcase_17 AC 3 ms
7,476 KB
testcase_18 AC 3 ms
7,472 KB
testcase_19 AC 22 ms
8,984 KB
testcase_20 AC 16 ms
8,456 KB
testcase_21 AC 17 ms
8,644 KB
testcase_22 AC 20 ms
9,028 KB
testcase_23 AC 21 ms
9,052 KB
testcase_24 AC 21 ms
8,960 KB
testcase_25 AC 9 ms
8,052 KB
testcase_26 AC 9 ms
8,044 KB
testcase_27 AC 9 ms
7,996 KB
testcase_28 AC 9 ms
8,000 KB
testcase_29 AC 9 ms
7,976 KB
testcase_30 AC 17 ms
8,520 KB
testcase_31 AC 17 ms
8,480 KB
testcase_32 AC 15 ms
8,280 KB
testcase_33 AC 13 ms
8,272 KB
testcase_34 AC 10 ms
8,272 KB
testcase_35 AC 15 ms
8,856 KB
testcase_36 AC 9 ms
8,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

void muri(){
	wt(0);
	exit(0);
}

char vis[2d5+1];
int ioc[2d5+1];
{
	unionFind u;
	u.walloc(2d5+1,1);
	ll@n;
	ll x=0,y=0,z=0;
	rep(n){
		ll@h,@w;
		vis[h]=1;
		vis[w]=1;
		ioc[h]+=1;
		ioc[w]-=1;
		u(h,w);
		x=h;
	}
	x=u(x);
	rep(i,1,2d5+1){
		if(vis[i]){
			if(u(i)!=x||ioc[i]<-1||ioc[i]>1){
				muri();
			}
			if(ioc[i]==-1){
				if(y&1){
					muri();
				}
				y|=1;
			}
			if(ioc[i]==1){
				if(y&2){
					muri();
				}
				y|=2;
			}
			z+=1;
		}
	}
	wt(y?1:z);
}
0