結果
| 問題 |
No.697 池の数はいくつか
|
| ユーザー |
Bantako
|
| 提出日時 | 2018-06-12 20:11:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 641 bytes |
| コンパイル時間 | 1,737 ms |
| コンパイル使用メモリ | 166,096 KB |
| 実行使用メモリ | 574,592 KB |
| 最終ジャッジ日時 | 2024-11-08 07:50:33 |
| 合計ジャッジ時間 | 15,495 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 MLE * 2 |
コンパイルメッセージ
main.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
18 | main(){
| ^~~~
ソースコード
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
int H,W;
int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};
bool V[3000][3000];
void dfs(int h,int w){
V[h][w] = 0;
rep(i,0,4){
int x = dx[i] + w, y = dy[i] + h;
if(x < 0 || x >= W || y < 0 || y >= H)continue;
if(V[y][x])dfs(y,x);
}
}
main(){
cin >> H >> W;
rep(i,0,H)rep(j,0,W)cin >> V[i][j];
int cnt = 0;
rep(i,0,H)rep(j,0,W){
if(V[i][j]){
cnt++;
dfs(i,j);
}
}
cout << cnt << endl;
}
Bantako