結果

問題 No.2675 KUMA
ユーザー tailstails
提出日時 2024-03-18 16:19:34
言語 Perl
(5.38.2)
結果
AC  
実行時間 1,550 ms / 2,000 ms
コード長 513 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 6,676 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-03-18 16:19:49
合計ジャッジ時間 14,463 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,676 KB
testcase_01 AC 12 ms
6,676 KB
testcase_02 AC 8 ms
6,676 KB
testcase_03 AC 8 ms
6,676 KB
testcase_04 AC 8 ms
6,676 KB
testcase_05 AC 798 ms
12,800 KB
testcase_06 AC 619 ms
13,056 KB
testcase_07 AC 8 ms
6,676 KB
testcase_08 AC 1,092 ms
12,928 KB
testcase_09 AC 306 ms
9,344 KB
testcase_10 AC 1,203 ms
12,928 KB
testcase_11 AC 1,039 ms
12,928 KB
testcase_12 AC 368 ms
7,936 KB
testcase_13 AC 10 ms
6,676 KB
testcase_14 AC 24 ms
6,676 KB
testcase_15 AC 9 ms
6,676 KB
testcase_16 AC 1,550 ms
12,928 KB
testcase_17 AC 8 ms
6,676 KB
testcase_18 AC 8 ms
6,676 KB
testcase_19 AC 8 ms
6,676 KB
testcase_20 AC 8 ms
6,676 KB
testcase_21 AC 8 ms
6,676 KB
testcase_22 AC 8 ms
6,676 KB
testcase_23 AC 8 ms
6,676 KB
testcase_24 AC 9 ms
6,676 KB
testcase_25 AC 9 ms
6,676 KB
testcase_26 AC 10 ms
6,676 KB
testcase_27 AC 10 ms
6,676 KB
testcase_28 AC 9 ms
6,676 KB
testcase_29 AC 10 ms
6,676 KB
testcase_30 AC 11 ms
6,676 KB
testcase_31 AC 22 ms
6,676 KB
testcase_32 AC 22 ms
6,676 KB
testcase_33 AC 22 ms
6,676 KB
testcase_34 AC 25 ms
6,676 KB
testcase_35 AC 42 ms
6,676 KB
testcase_36 AC 71 ms
6,676 KB
testcase_37 AC 68 ms
6,676 KB
testcase_38 AC 129 ms
7,040 KB
testcase_39 AC 110 ms
7,040 KB
testcase_40 AC 144 ms
7,040 KB
testcase_41 AC 290 ms
7,808 KB
testcase_42 AC 321 ms
7,936 KB
testcase_43 AC 266 ms
7,936 KB
testcase_44 AC 291 ms
7,808 KB
testcase_45 AC 615 ms
9,600 KB
testcase_46 AC 600 ms
9,600 KB
testcase_47 AC 625 ms
9,600 KB
testcase_48 AC 1,018 ms
12,928 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

$;=$";
@d=(-2,-2,-1,+1,+2,+2,+1,-1);
$n=<>;
for(0..$n-1){
	($x[$_],$y[$_])=($x,$y)=glob<>;
	$p{$x,$y}=1<<$_;
	for$j(0..7){
		$k{$x-$d[$j+6&7],$y-$d[$j]}=1;
	}
}
for(0..$n-1){
	delete $k{$x[$_],$y[$_]};
}
$b[0]=0;
for(keys%k){
	@a=@b;
	$k=$k{$_};
	($x,$y)=glob;
	for$j(0,2,4,6){
		$p=0;
		for(0,1){
			$p|=$p{$x+$d[$j+6&7^$_],$y+$d[$j^$_]};
		}
		if($p){
			for(0..(1<<$n)-1){
				if(defined$a[$_]){
					$b[$_|$p]=$a[$_]+1 if !defined $b[$_|$p] || $b[$_|$p]>$a[$_]+1;
				}
			}
		}
	}
}
print $b[(1<<$n)-1]//-1;
0