結果

問題 No.697 池の数はいくつか
ユーザー siro53siro53
提出日時 2018-12-26 14:40:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,156 bytes
コンパイル時間 918 ms
コンパイル使用メモリ 89,916 KB
実行使用メモリ 601,216 KB
最終ジャッジ日時 2024-05-04 06:19:57
合計ジャッジ時間 13,870 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 172 ms
11,520 KB
testcase_25 AC 172 ms
11,648 KB
testcase_26 AC 172 ms
11,520 KB
testcase_27 AC 172 ms
11,648 KB
testcase_28 AC 172 ms
11,520 KB
testcase_29 MLE -
testcase_30 AC 1,612 ms
38,824 KB
testcase_31 MLE -
testcase_32 AC 1,528 ms
38,640 KB
testcase_33 AC 1,524 ms
38,820 KB
testcase_34 AC 1,516 ms
38,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

//入力
int h, w;
int a[3000][3001];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void dfs(int y, int x)
{
    a[y][x] = 0;
    for(int i=0;i<4;i++){
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(0<=nx&&nx<w&&0<=ny&&ny<h&&a[ny][nx]==1)
            dfs(ny, nx);
    }
    return;
}

void solve()
{
    int ans = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]==1){
                dfs(i, j);
                ans++;
            }
        }
    }
    printf("%d\n", ans);
}

int main()
{
    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> a[i][j];
        }
    }
    solve();
}
0