結果
| 問題 | No.697 池の数はいくつか |
| ユーザー |
prtoq3
|
| 提出日時 | 2018-10-21 18:21:45 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 767 bytes |
| 記録 | |
| コンパイル時間 | 1,510 ms |
| コンパイル使用メモリ | 158,596 KB |
| 実行使用メモリ | 601,132 KB |
| 最終ジャッジ日時 | 2024-11-25 14:25:19 |
| 合計ジャッジ時間 | 14,084 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 MLE * 2 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int MAX_N = 3010;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
int field[MAX_N][MAX_N];
int h, w;
void dfs(int x, int y){
field[x][y] = 0;
for (int i = 0; i < 4; i++){
int nx = x + dx[i];
int ny = y + dy[i];
if (0 <= nx && nx < h && 0 <= ny && ny < w && field[nx][ny]){
dfs(nx, ny);
}
}
}
int main(){
cin >> h >> w;
int i, j;
REP(i, h) REP(j, w) cin >> field[i][j];
int ans = 0;
REP(i, h) REP(j, w){
if (field[i][j]){
dfs(i, j);
ans++;
}
}
cout << ans << endl;
return 0;
}
prtoq3