結果

問題 No.697 池の数はいくつか
ユーザー amtgjwamtgjw
提出日時 2018-06-10 17:19:42
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,297 bytes
コンパイル時間 671 ms
コンパイル使用メモリ 69,192 KB
実行使用メモリ 776,704 KB
最終ジャッジ日時 2024-05-04 05:40:15
合計ジャッジ時間 16,172 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 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,940 KB
testcase_24 AC 189 ms
11,264 KB
testcase_25 AC 182 ms
11,392 KB
testcase_26 AC 180 ms
11,264 KB
testcase_27 AC 178 ms
11,264 KB
testcase_28 AC 179 ms
11,264 KB
testcase_29 MLE -
testcase_30 AC 1,630 ms
73,600 KB
testcase_31 MLE -
testcase_32 AC 1,570 ms
73,600 KB
testcase_33 AC 1,585 ms
73,600 KB
testcase_34 AC 1,558 ms
73,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)
#define PER(i,n)	for(int i=0;i>(n);--i)
#define PERS(i,s,t)	for(int i=(s);i>(t);--i)

#define INF 		2000000007
#define MINF		-200000007
#define MOD			17 	
// 2^20

#define MAX 		200005

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}

//int dp[MAX];
int H,W;

void check(vector<vector<int> > &A,vector<vector<int> > &dp,int x,int y){
	if(0>x||x>=H)return;
	if(0>y||y>=W)return;
	if(A[x][y]==0||dp[x][y]==1) return;
	else{
		dp[x][y] = 1;
		check(A,dp,x+1,y);
		check(A,dp,x,y+1);
		check(A,dp,x-1,y);
		check(A,dp,x,y-1);
	}
}

int main(){
	cin>>H>>W;
	int cnt=0;

	vector<vector<int> > A(H,vector<int>(W,false));
	cin>>A;

	vector<vector<int> > dp(H,vector<int>(W,false));

	REP(i,H){
		REP(j,W){
			if(A[i][j]==0){dp[i][j]=1;continue;}
			if(dp[i][j]==1)continue;
			cnt++;
			check(A,dp,i,j);
		}
	}

	cout << cnt << endl;

	return 0;
}
0