結果

問題 No.459 C-VS for yukicoder
ユーザー tails
提出日時 2016-12-10 01:12:17
言語 Perl
(5.40.0)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 1,003 bytes
コンパイル時間 225 ms
コンパイル使用メモリ 6,948 KB
実行使用メモリ 21,360 KB
最終ジャッジ日時 2024-11-28 21:07:48
合計ジャッジ時間 3,668 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 58
権限があれば一括ダウンロードができます
コンパイルメッセージ
Name "main::y" used only once: possible typo at Main.pl line 2.
Main.pl syntax OK

ソースコード

diff #

($h,$w,$n)=glob<>;
for$y(1..$h){
	$_=<>;
	for$x(0..$w-1){
		if(substr($_,$x,1)eq'#'){
			++$a[$x];
		}
	}
}
for$t(0..$n-1){
	$c=<>;
	$t[$c]=$t;
	$e[$c+0]+=3;
	$e[$c+1]+=3;
	$e[$c+2]+=3;
	push@b,sprintf"%6d,%6d",$c,$t;
}
@b=sort@b;
for$j(0..$#b){
	$_=$b[$j];
	/,/,$c=$`,$t=$';
	$j[$t]=$j;
	$e[$c+0]-=3; $a[$c+0]-=$r[$j][0]=$-=$a[$c+0]-$e[$c+0]; 
	$e[$c+1]-=3; $a[$c+1]-=$r[$j][1]=$-=$a[$c+1]-$e[$c+1]; 
	$e[$c+2]-=3; $a[$c+2]-=$r[$j][2]=$-=$a[$c+2]-$e[$c+2]; 
	if($r[$j][0]+$r[$j][1]+$r[$j][2]==0){
		if($a[$c+0]){
			$r[$j][0]=1;
			--$a[$c+0];
		}elsif($a[$c+1]){
			$r[$j][1]=1;
			--$a[$c+1];
		}elsif($a[$c+2]){
			$r[$j][2]=1;
			--$a[$c+2];
		}else{
		last;
			#die;
		}
	}
}
for$t(0..$n-1){
	$j=$j[$t];
	print $r[$j][0]>0?'#':'.';
	print $r[$j][1]>0?'#':'.';
	print $r[$j][2]>0?'#':'.';
	print "\n";
	print $r[$j][0]>1?'#':'.';
	print $r[$j][1]>1?'#':'.';
	print $r[$j][2]>1?'#':'.';
	print "\n";
	print $r[$j][0]>2?'#':'.';
	print $r[$j][1]>2?'#':'.';
	print $r[$j][2]>2?'#':'.';
	print "\n";
}
0