結果

問題 No.5002 stick xor
ユーザー %20%20
提出日時 2018-05-26 00:31:48
言語 Perl
(5.38.2)
結果
AC  
実行時間 904 ms / 1,000 ms
コード長 733 bytes
コンパイル時間 28,494 ms
実行使用メモリ 3,384 KB
スコア 39,737
最終ジャッジ日時 2018-05-26 00:32:18
ジャッジサーバーID
(参考情報)
judge8 /
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 802 ms
3,384 KB
testcase_01 AC 828 ms
3,380 KB
testcase_02 AC 783 ms
3,384 KB
testcase_03 AC 844 ms
3,384 KB
testcase_04 AC 785 ms
3,380 KB
testcase_05 AC 855 ms
3,384 KB
testcase_06 AC 849 ms
3,384 KB
testcase_07 AC 798 ms
3,384 KB
testcase_08 AC 904 ms
3,380 KB
testcase_09 AC 805 ms
3,380 KB
testcase_10 AC 843 ms
3,384 KB
testcase_11 AC 781 ms
3,380 KB
testcase_12 AC 846 ms
3,384 KB
testcase_13 AC 811 ms
3,384 KB
testcase_14 AC 811 ms
3,380 KB
testcase_15 AC 872 ms
3,380 KB
testcase_16 AC 779 ms
3,384 KB
testcase_17 AC 843 ms
3,380 KB
testcase_18 AC 804 ms
3,384 KB
testcase_19 AC 869 ms
3,384 KB
testcase_20 AC 844 ms
3,384 KB
testcase_21 AC 812 ms
3,380 KB
testcase_22 AC 844 ms
3,384 KB
testcase_23 AC 786 ms
3,380 KB
testcase_24 AC 840 ms
3,380 KB
testcase_25 AC 791 ms
3,380 KB
testcase_26 AC 848 ms
3,384 KB
testcase_27 AC 841 ms
3,384 KB
testcase_28 AC 776 ms
3,380 KB
testcase_29 AC 845 ms
3,380 KB
testcase_30 AC 798 ms
3,384 KB
testcase_31 AC 858 ms
3,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Name "main::K" used only once: possible typo at Main.pl line 2.
Main.pl syntax OK

ソースコード

diff #

$,=$";$\=$/;
($N,$K)=glob<>;
@s=sort{$b-$a}@L=glob<>;
@A=map[/./g],map~~<>,1..$N;
for$l(@s){
	$C=-1;
	for$y(0..$N-1){
		$c=0;
		for$x(0..$l-1){
			$c+=$A[$y][$x]
		}
		if($c>$C){
			$C=$c;$Y=$y;$X=$l-1
		}
		for$x($l..$N-1){
			$c+=$A[$y][$x]-$A[$y][$x-$l];
			if($c>$C){
				$C=$c;$Y=$y;$X=$x
			}
		}
	}
	$D=-1;
	for$x(0..$N-1){
		$c=0;
		for$y(0..$l-1){
			$c+=$A[$y][$x]
		}
		if($c>$D){
			$D=$c;$YY=$l-1;$XX=$x
		}
		for$y($l..$N-1){
			$c+=$A[$y][$x]-$A[$y-$l][$x];
			if($c>$D){
				$D=$c;$YY=$y;$XX=$x
			}
		}
	}
	if($C>$D){
		push@$l,[$Y+1,$X-$l+2,$Y+1,$X+1];
		for$x($X-$l+1..$X){
			$A[$Y][$x]^=1
		}
	}else{
		push@$l,[$YY-$l+2,$XX+1,$YY+1,$XX+1];
		for$y($YY-$l+1..$YY){
			$A[$y][$XX]^=1
		}
	}
}
print@{pop@$_}for@L
0