結果

問題 No.697 池の数はいくつか
ユーザー amtgjwamtgjw
提出日時 2018-06-10 17:21:45
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,151 bytes
コンパイル時間 606 ms
コンパイル使用メモリ 69,028 KB
実行使用メモリ 600,704 KB
最終ジャッジ日時 2024-05-04 05:39:46
合計ジャッジ時間 12,628 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 1 ms
6,940 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 157 ms
7,296 KB
testcase_25 AC 153 ms
7,168 KB
testcase_26 AC 151 ms
7,424 KB
testcase_27 AC 151 ms
7,424 KB
testcase_28 AC 151 ms
7,296 KB
testcase_29 MLE -
testcase_30 AC 1,389 ms
38,528 KB
testcase_31 MLE -
testcase_32 AC 1,401 ms
38,400 KB
testcase_33 AC 1,408 ms
38,528 KB
testcase_34 AC 1,407 ms
38,400 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,int x,int y){
	if(0>x||x>=H)return;
	if(0>y||y>=W)return;
	if(A[x][y]==0) return;
	else{
		A[x][y] = 0;
		check(A,x+1,y);
		check(A,x,y+1);
		check(A,x-1,y);
		check(A,x,y-1);
	}
}

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

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

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

	cout << cnt << endl;

	return 0;
}
0