結果
問題 |
No.697 池の数はいくつか
|
ユーザー |
|
提出日時 | 2018-06-26 01:37:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,709 ms / 6,000 ms |
コード長 | 685 bytes |
コンパイル時間 | 984 ms |
コンパイル使用メモリ | 74,840 KB |
実行使用メモリ | 47,360 KB |
最終ジャッジ日時 | 2024-11-08 07:58:27 |
合計ジャッジ時間 | 14,035 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 8 | main() | ^~~~
ソースコード
#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; }