結果

問題 No.697 池の数はいくつか
ユーザー kotatsugamekotatsugame
提出日時 2018-06-26 01:37:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,635 ms / 6,000 ms
コード長 685 bytes
コンパイル時間 785 ms
コンパイル使用メモリ 76,364 KB
実行使用メモリ 47,564 KB
最終ジャッジ日時 2024-04-25 20:13:09
合計ジャッジ時間 13,296 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 179 ms
20,812 KB
testcase_25 AC 180 ms
20,808 KB
testcase_26 AC 181 ms
18,888 KB
testcase_27 AC 176 ms
18,632 KB
testcase_28 AC 186 ms
20,680 KB
testcase_29 AC 1,509 ms
47,556 KB
testcase_30 AC 1,635 ms
47,560 KB
testcase_31 AC 1,510 ms
47,436 KB
testcase_32 AC 1,602 ms
47,436 KB
testcase_33 AC 1,566 ms
47,560 KB
testcase_34 AC 1,568 ms
47,564 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<queue>
using namespace std;
int map[3000][3000];
bool used[3000][3000];
int h,w;
int cnt,dx[]={0,1,0,-1},dy[]={1,0,-1,0};
main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>map[i][j];
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)
	{
		if(used[i][j]||map[i][j]==0)continue;
		queue<pair<int,int> >P;
		P.push(make_pair(i,j));
		used[i][j]=1;
		while(!P.empty())
		{
			int x=P.front().first,y=P.front().second;
			P.pop();
			for(int r=0;r<4;r++)
			{
				int tx=x+dx[r],ty=y+dy[r];
				if(tx<0||ty<0||tx>=h||ty>=w||map[tx][ty]==0||used[tx][ty])continue;
				used[tx][ty]=1;
				P.push(make_pair(tx,ty));
			}
		}
		cnt++;
	}
	cout<<cnt<<endl;
}
0