結果

問題 No.307 最近色塗る問題多くない?
ユーザー tailstails
提出日時 2015-11-27 23:14:16
言語 Perl
(5.38.2)
結果
TLE  
実行時間 -
コード長 503 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 5,168 KB
実行使用メモリ 59,716 KB
最終ジャッジ日時 2023-10-12 00:40:31
合計ジャッジ時間 22,599 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
11,732 KB
testcase_01 AC 3 ms
4,860 KB
testcase_02 AC 2 ms
4,584 KB
testcase_03 AC 3 ms
4,576 KB
testcase_04 AC 12 ms
6,100 KB
testcase_05 AC 4 ms
4,916 KB
testcase_06 AC 4 ms
5,016 KB
testcase_07 AC 127 ms
12,292 KB
testcase_08 AC 1,328 ms
49,744 KB
testcase_09 AC 469 ms
31,396 KB
testcase_10 AC 27 ms
5,944 KB
testcase_11 AC 66 ms
7,628 KB
testcase_12 AC 4 ms
4,652 KB
testcase_13 AC 70 ms
4,856 KB
testcase_14 AC 46 ms
8,432 KB
testcase_15 AC 73 ms
9,824 KB
testcase_16 AC 68 ms
7,664 KB
testcase_17 AC 1,208 ms
29,688 KB
testcase_18 TLE -
testcase_19 AC 3,513 ms
45,288 KB
testcase_20 AC 8 ms
5,140 KB
testcase_21 AC 2,514 ms
36,980 KB
testcase_22 AC 2,116 ms
59,716 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

($h,$w)=<>=~/\d+/g;
for$y(1..$h){
	@f{map"$_,$y",1..$w}=<>=~/\d/g;
}

sub f{
	my($x,$y)=@_;
	if($x>0&&$x<=$w&&$y>0&&$y<=$h){
		if($f{"$x,$y"}==$c){
			$f{"$x,$y"}=$d;
			++$t;
			f($x-1,$y);
			f($x+1,$y);
			f($x,$y-1);
			f($x,$y+1);
		}
	}
}

for(1..<>){
	($y,$x,$d)=<>=~/\d+/g;
	if(!$n && $f{"$x,$y"}!=$d){
		$t=0;
		$c=1-$d;
		f($x,$y);
		if($t==$h*$w){
			$n=1;
		}
	}
}

if($n){
	for$y(1..$h){
		print join($",($d)x$w),$/;
	}
}else{
	for$y(1..$h){
		print join($",@f{map"$_,$y",1..$w}),$/;
	}
}

0