結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 1 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 1 ms
6,948 KB
testcase_24 AC 151 ms
16,104 KB
testcase_25 AC 150 ms
14,836 KB
testcase_26 AC 151 ms
15,100 KB
testcase_27 AC 153 ms
16,388 KB
testcase_28 AC 155 ms
15,032 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++)
using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
const ll inf = 1e16;
const ll md = 1000000007;

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

void dfs(int i,int j){
  a[i][j]=0;
  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]==0) continue;
    dfs(ni,nj);
  }
}

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