結果

問題 No.697 池の数はいくつか
ユーザー mkawa2mkawa2
提出日時 2020-01-23 16:36:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 581 bytes
コンパイル時間 1,622 ms
コンパイル使用メモリ 167,672 KB
実行使用メモリ 814,324 KB
最終ジャッジ日時 2024-05-04 06:51:19
合計ジャッジ時間 7,063 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 169 ms
6,940 KB
testcase_25 AC 168 ms
8,208 KB
testcase_26 AC 168 ms
6,968 KB
testcase_27 AC 169 ms
7,448 KB
testcase_28 AC 170 ms
8,240 KB
testcase_29 MLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

bool a[3005][3005];
int h,w;

void dfs(int i,int j){
  a[i][j]=false;
  rep(ij,2) rep(pm,2){
    int ni=i+(pm*2-1)*ij;
    int nj=j+(pm*2-1)*(1-ij);
    if(ni<0 || nj<0 || ni>=h || nj>=w) continue;
    if(a[ni][nj]==false) continue;
    dfs(ni,nj);
  }
}

int main() {
  cin>>h>>w;
  rep(i,h) rep(j,w){
    int aij;
    cin>>aij;
    a[i][j]=(aij==1);
    }
  int ans=0;
  rep(i,h) rep(j,w){
    if(a[i][j]==false) continue;
    ans++;
    dfs(i,j);
  }
  cout<<ans<<endl;
  return 0;
}
0