結果
問題 |
No.697 池の数はいくつか
|
ユーザー |
|
提出日時 | 2018-06-10 22:54:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 659 bytes |
コンパイル時間 | 698 ms |
コンパイル使用メモリ | 65,280 KB |
実行使用メモリ | 38,788 KB |
最終ジャッジ日時 | 2024-11-25 13:13:51 |
合計ジャッジ時間 | 11,831 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 11 WA * 21 |
ソースコード
#include <iostream> #define MAX_H 3000 #define MAX_W 3000 using namespace std; int H,W; int A[MAX_H][MAX_W]; void dfs(int x, int y){ A[y][x] = 0; int nx, ny; nx=x; ny=y+1; if(ny<H && A[ny][nx]==1) dfs(nx,ny); nx=x+1; ny=y; if(nx<W && A[ny][nx]==1) dfs(nx,ny); } void solve(){ int res = 0; for(int j=0;j<H;j++){ for(int i=0;i<W;i++){ if(A[j][i]==1){ dfs(i,j); res++; } } } cout << res << endl; } int main(){ cin >> H >> W; for(int j=0; j<H; j++) for(int i=0; i<W;i++) cin >> A[j][i]; solve(); }