結果
| 問題 | No.697 池の数はいくつか |
| ユーザー |
troro_kelp
|
| 提出日時 | 2018-10-16 17:03:03 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,007 bytes |
| 記録 | |
| コンパイル時間 | 527 ms |
| コンパイル使用メモリ | 70,656 KB |
| 実行使用メモリ | 434,036 KB |
| 最終ジャッジ日時 | 2024-11-25 14:25:00 |
| 合計ジャッジ時間 | 11,739 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 MLE * 2 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int H, W;
int dxy[5] = {-1, 0, 1, 0, -1};
bool v[3005][3005];
int ans;
void dfs(int y, int x)
{
if (v[y][x] == false)
return;
v[y][x] = 0;
for (int i = 1; i < 5; ++i)
{
int ny = y + dxy[i], nx = x + dxy[i - 1];
if (ny >= 0 && nx >= 0 && ny < H && nx < W && v[ny][nx] != false)
{
dfs(ny, nx);
}
}
return;
}
int main(void)
{
cin >> H >> W;
for (int i = 0; i < H; ++i)
{
for (int j = 0; j < W; ++j)
{
int a;
cin >> a;
if (a == 1)
v[i][j] = true;
else
v[i][j] = false;
}
}
for (int i = 0; i < H; ++i)
{
for (int j = 0; j < W; ++j)
{
if (v[i][j])
{
dfs(i, j);
ans++;
}
}
}
cout << ans << endl;
return 0;
}
troro_kelp