結果

問題 No.1640 簡単な色塗り
ユーザー tailstails
提出日時 2021-08-10 21:51:37
言語 Perl
(5.38.2)
結果
AC  
実行時間 708 ms / 2,000 ms
コード長 579 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 5,288 KB
実行使用メモリ 78,576 KB
最終ジャッジ日時 2023-09-12 04:06:48
合計ジャッジ時間 28,020 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,648 KB
testcase_01 AC 3 ms
4,696 KB
testcase_02 AC 3 ms
4,644 KB
testcase_03 AC 3 ms
4,560 KB
testcase_04 AC 619 ms
78,412 KB
testcase_05 AC 606 ms
78,576 KB
testcase_06 AC 2 ms
4,700 KB
testcase_07 AC 3 ms
4,756 KB
testcase_08 AC 3 ms
4,696 KB
testcase_09 AC 3 ms
4,696 KB
testcase_10 AC 389 ms
48,252 KB
testcase_11 AC 305 ms
40,540 KB
testcase_12 AC 271 ms
36,440 KB
testcase_13 AC 658 ms
71,608 KB
testcase_14 AC 658 ms
71,420 KB
testcase_15 AC 195 ms
27,868 KB
testcase_16 AC 243 ms
33,112 KB
testcase_17 AC 529 ms
60,584 KB
testcase_18 AC 39 ms
9,672 KB
testcase_19 AC 282 ms
36,372 KB
testcase_20 AC 401 ms
46,804 KB
testcase_21 AC 312 ms
39,572 KB
testcase_22 AC 26 ms
8,168 KB
testcase_23 AC 422 ms
50,012 KB
testcase_24 AC 98 ms
17,716 KB
testcase_25 AC 285 ms
37,032 KB
testcase_26 AC 489 ms
55,964 KB
testcase_27 AC 192 ms
26,640 KB
testcase_28 AC 626 ms
68,376 KB
testcase_29 AC 479 ms
55,396 KB
testcase_30 AC 90 ms
15,836 KB
testcase_31 AC 694 ms
76,624 KB
testcase_32 AC 590 ms
67,384 KB
testcase_33 AC 390 ms
47,152 KB
testcase_34 AC 499 ms
58,188 KB
testcase_35 AC 403 ms
47,144 KB
testcase_36 AC 84 ms
15,680 KB
testcase_37 AC 122 ms
19,828 KB
testcase_38 AC 631 ms
70,220 KB
testcase_39 AC 234 ms
32,992 KB
testcase_40 AC 259 ms
33,652 KB
testcase_41 AC 536 ms
59,864 KB
testcase_42 AC 296 ms
37,404 KB
testcase_43 AC 290 ms
38,672 KB
testcase_44 AC 297 ms
38,052 KB
testcase_45 AC 214 ms
30,144 KB
testcase_46 AC 95 ms
17,144 KB
testcase_47 AC 58 ms
12,612 KB
testcase_48 AC 645 ms
71,548 KB
testcase_49 AC 26 ms
8,160 KB
testcase_50 AC 3 ms
4,700 KB
testcase_51 AC 3 ms
4,760 KB
testcase_52 AC 703 ms
78,248 KB
testcase_53 AC 708 ms
78,504 KB
07_evil_01.txt AC 1,609 ms
154,400 KB
07_evil_02.txt TLE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

sub muri{
	print"No\n";
	exit;
}

$n=<>;

@evv=map{
	($a,$b)=<>=~/\w+/g;
	push@$a,$_;
	push@$b,$_;
	$a+$b;
}0..$n-1;

@vn=map~~@$_,0..$n;
@q=grep$vn[$_]==1,1..$n;

while(@q){
	$vi=pop@q;
	$vn[$vi]=-1;
	for$ei(grep!$ans[$_],@$vi){
		$vj=$evv[$ei]-$vi;
		$d=--$vn[$vj];
		if($d==0){
			muri;
		}
		$ans[$ei]=$vi;
		if($d==1){
			push@q,$vj;
		}
	}
}

for$vi(1..$n){
	if($vn[$vi]>=0){
		$vo=$vi;
		do{
			$vn[$vi]=-1;
			for$ei(grep!$ans[$_],@$vi){
				$ans[$ei]=$vi;
				$vi=$evv[$ei]-$vi;
				goto hoge;
			}
			muri;
			hoge:;
		}while($vi!=$vo);
	}
}

print $_,$/ for Yes,@ans;
0