結果
| 問題 |
No.697 池の数はいくつか
|
| ユーザー |
kuroi_13
|
| 提出日時 | 2018-06-12 15:24:07 |
| 言語 | Perl (5.40.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 827 bytes |
| コンパイル時間 | 313 ms |
| コンパイル使用メモリ | 6,820 KB |
| 実行使用メモリ | 769,312 KB |
| 最終ジャッジ日時 | 2024-11-25 13:29:18 |
| 合計ジャッジ時間 | 58,201 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | MLE * 3 |
| other | AC * 24 TLE * 5 MLE * 3 |
コンパイルメッセージ
Main.pl syntax OK
ソースコード
use strict;
use warnings;
my($h, $w) = split ' ', <>;
my @map;
for(<>){
push @map, [split ' ', $_];
}
my @queue = ();
my @vx = (0, 1, 0, -1);
my @vy = (1, 0, -1, 0);
my $count = 0;
my($pres, $next);
for my $y (0..$h-1){
for my $x (0..$w-1){
if($map[$y][$x] == 1){
$map[$y][$x]++;
push @queue, {x => $x, y => $y};
while(@queue){
$pres = shift @queue;
for my $i (0..3){
$next = {x => $pres->{x} + $vx[$i], y => $pres->{y} + $vy[$i]};
if(-1 < $next->{x} and $next->{x} < $w and -1 < $next->{y} and $next->{y} < $h){
if($map[$next->{y}][$next->{x}] == 1){
$map[$next->{y}][$next->{x}]++;
push @queue, {x => $next->{x}, y => $next->{y}};
}
}
}
}
$count++;
}
}
}
print $count."\n";
kuroi_13