結果

問題 No.697 池の数はいくつか
ユーザー kuroi_13kuroi_13
提出日時 2018-06-12 15:24:07
言語 Perl
(5.38.2)
結果
MLE  
実行時間 -
コード長 827 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 6,820 KB
実行使用メモリ 744,096 KB
最終ジャッジ日時 2024-05-04 05:50:09
合計ジャッジ時間 21,556 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
6,816 KB
testcase_01 AC 5 ms
6,944 KB
testcase_02 AC 5 ms
6,944 KB
testcase_03 AC 5 ms
6,944 KB
testcase_04 AC 5 ms
6,944 KB
testcase_05 AC 5 ms
6,940 KB
testcase_06 AC 5 ms
6,940 KB
testcase_07 AC 6 ms
6,940 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 AC 5 ms
6,944 KB
testcase_10 AC 6 ms
6,940 KB
testcase_11 AC 5 ms
6,940 KB
testcase_12 AC 5 ms
6,944 KB
testcase_13 AC 5 ms
6,944 KB
testcase_14 AC 5 ms
6,940 KB
testcase_15 AC 6 ms
6,940 KB
testcase_16 AC 5 ms
6,944 KB
testcase_17 AC 5 ms
6,940 KB
testcase_18 AC 5 ms
6,940 KB
testcase_19 AC 5 ms
6,940 KB
testcase_20 AC 6 ms
6,944 KB
testcase_21 AC 6 ms
6,940 KB
testcase_22 AC 5 ms
6,944 KB
testcase_23 AC 5 ms
6,944 KB
testcase_24 AC 2,467 ms
108,544 KB
testcase_25 AC 2,434 ms
108,544 KB
testcase_26 AC 2,432 ms
108,416 KB
testcase_27 AC 2,499 ms
108,544 KB
testcase_28 AC 2,416 ms
108,544 KB
testcase_29 MLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

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";
0