結果

問題 No.697 池の数はいくつか
ユーザー utouto97utouto97
提出日時 2019-01-21 22:52:23
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,108 bytes
コンパイル時間 2,372 ms
コンパイル使用メモリ 143,580 KB
実行使用メモリ 750,272 KB
最終ジャッジ日時 2023-08-16 22:58:56
合計ジャッジ時間 14,945 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,472 KB
testcase_01 AC 2 ms
5,388 KB
testcase_02 AC 2 ms
5,404 KB
testcase_03 AC 2 ms
5,588 KB
testcase_04 AC 2 ms
5,408 KB
testcase_05 AC 2 ms
5,424 KB
testcase_06 AC 2 ms
5,412 KB
testcase_07 AC 2 ms
5,404 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,392 KB
testcase_10 AC 2 ms
5,396 KB
testcase_11 AC 2 ms
5,408 KB
testcase_12 AC 2 ms
5,440 KB
testcase_13 AC 2 ms
5,472 KB
testcase_14 AC 2 ms
5,472 KB
testcase_15 AC 2 ms
5,592 KB
testcase_16 AC 2 ms
5,396 KB
testcase_17 AC 2 ms
5,412 KB
testcase_18 AC 2 ms
5,384 KB
testcase_19 AC 2 ms
5,388 KB
testcase_20 AC 2 ms
5,460 KB
testcase_21 AC 2 ms
5,392 KB
testcase_22 AC 2 ms
5,428 KB
testcase_23 AC 2 ms
5,416 KB
testcase_24 AC 172 ms
20,616 KB
testcase_25 AC 171 ms
20,620 KB
testcase_26 AC 173 ms
20,664 KB
testcase_27 AC 172 ms
20,620 KB
testcase_28 AC 171 ms
20,616 KB
testcase_29 MLE -
testcase_30 WA -
testcase_31 MLE -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=int(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

int h, w;
int a[3000][3000];
bool used[3000][3000];

int dfs(int y, int x)
{
  if(used[y][x]) return 0;

  used[y][x] = true;
  int dd[] = {1, 0, -1, 0, 1};
  rep(i, 4){
    int nx = x + dd[i];
    int ny = y + dd[i+1];

    if(nx < 0 or w <= x or ny < 0 or h <= ny) continue;
    if(a[ny][nx] == 1){
      dfs(ny, nx);
    }
  }

  return 1;
}

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] == 1)
        ans += dfs(i, j); 
    }
  }
  cout << ans << endl;

  return 0;
}
0