結果
問題 |
No.697 池の数はいくつか
|
ユーザー |
![]() |
提出日時 | 2020-01-23 16:36:21 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 581 bytes |
コンパイル時間 | 1,453 ms |
コンパイル使用メモリ | 167,112 KB |
実行使用メモリ | 814,488 KB |
最終ジャッジ日時 | 2024-11-25 15:48:48 |
合計ジャッジ時間 | 14,789 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 MLE * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (n); i++) bool a[3005][3005]; int h,w; void dfs(int i,int j){ a[i][j]=false; rep(ij,2) rep(pm,2){ int ni=i+(pm*2-1)*ij; int nj=j+(pm*2-1)*(1-ij); if(ni<0 || nj<0 || ni>=h || nj>=w) continue; if(a[ni][nj]==false) continue; dfs(ni,nj); } } int main() { cin>>h>>w; rep(i,h) rep(j,w){ int aij; cin>>aij; a[i][j]=(aij==1); } int ans=0; rep(i,h) rep(j,w){ if(a[i][j]==false) continue; ans++; dfs(i,j); } cout<<ans<<endl; return 0; }