結果
| 問題 |
No.697 池の数はいくつか
|
| ユーザー |
|
| 提出日時 | 2018-06-11 00:03:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 579 bytes |
| コンパイル時間 | 659 ms |
| コンパイル使用メモリ | 65,064 KB |
| 実行使用メモリ | 741,504 KB |
| 最終ジャッジ日時 | 2024-11-25 13:16:58 |
| 合計ジャッジ時間 | 13,455 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 WA * 20 MLE * 2 |
ソースコード
#include <iostream>
int H,W;
int A[3001][3001];
int res = 0;
void dfs(int x, int y){
A[y][x] = 0;
if(y+1<H && A[y+1][x]) dfs(x,y+1);
if(y-1>=0 && A[y-1][x]) dfs(x,y-1);
if(x+1<W && A[y][x+1]) dfs(x+1,y);
//if(x-1>=0 && A[y][x-1]) dfs(x-1,y);
}
int main(){
std::cin >> H >> W;
for(int j=0; j<H; j++) for(int i=0; i<W;i++) std::cin >> A[j][i];
for(int j=0;j<H;j++){
for(int i=0;i<W;i++){
if(A[j][i]){
dfs(i,j);
res++;
}
}
}
std::cout << res << std::endl;
}