結果

問題 No.460 裏表ちわーわ
ユーザー tailstails
提出日時 2016-12-11 00:39:07
言語 Perl
(5.38.2)
結果
WA  
実行時間 -
コード長 599 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 5,300 KB
実行使用メモリ 5,340 KB
最終ジャッジ日時 2023-08-19 10:53:13
合計ジャッジ時間 27,138 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
5,176 KB
testcase_01 AC 8 ms
5,168 KB
testcase_02 AC 119 ms
5,176 KB
testcase_03 AC 6 ms
5,080 KB
testcase_04 AC 5 ms
5,220 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1,353 ms
5,104 KB
testcase_09 AC 19 ms
5,036 KB
testcase_10 AC 1,362 ms
5,092 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 1,470 ms
5,268 KB
testcase_14 AC 1,360 ms
5,184 KB
testcase_15 AC 1,395 ms
5,176 KB
testcase_16 WA -
testcase_17 AC 1,310 ms
5,232 KB
testcase_18 AC 1,362 ms
5,104 KB
testcase_19 AC 1,410 ms
5,192 KB
testcase_20 WA -
testcase_21 AC 1,342 ms
5,156 KB
testcase_22 AC 1,337 ms
5,104 KB
testcase_23 AC 1,370 ms
5,104 KB
testcase_24 AC 1,391 ms
5,192 KB
testcase_25 AC 7 ms
5,228 KB
testcase_26 AC 7 ms
5,076 KB
testcase_27 AC 8 ms
5,112 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

($m,$n)=glob<>;
push@a,[glob]for<>;
$b=99;

sub d {
	my($y,$x)=@_;
	for$j($y-1..$y+1){
		if($j>=0&&$j<$m){
			for$i($x-1..$x+1){
				if($i>=0&&$i<$n){
					$a[$j][$i]^=1;
				}
			}
		}
	}
}

sub f {
	my($y,$x,$c)=@_;
	
	if($x==$n){
		$x=0;++$y;
	}
	if($y==$m){
		for$j(0..$m-1){
			for$i(0..$n-1){
				if($a[$j][$i]){
					return;
				}
			}
		}
		if($b>$c){
			$b=$c;
		}
		return;
	}

	if($y>0&&$x>0){
		if($a[$y-1][$x-1]){
			d($y,$x);
			f($y,$x+1,$c+1);
			d($y,$x);
		}else{
			f($y,$x+1,$c);
		}
	}else{
		f($y,$x+1,$c);
		d($y,$x);
		f($y,$x+1,$c+1);
		d($y,$x);
	}
}		

f(0,0,0);
print $b;
0