結果
| 問題 | No.697 池の数はいくつか |
| ユーザー |
lunnear
|
| 提出日時 | 2018-11-22 15:19:41 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1,098 ms / 6,000 ms |
| コード長 | 1,003 bytes |
| 記録 | |
| コンパイル時間 | 487 ms |
| コンパイル使用メモリ | 71,148 KB |
| 実行使用メモリ | 293,376 KB |
| 最終ジャッジ日時 | 2026-05-20 04:50:28 |
| 合計ジャッジ時間 | 9,326 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <iostream>
enum State
{
None = -1,
Field,
Lake,
Lake_Check,
};
int g_w, g_h;
char *state;
bool ChechLake(short x, short y)
{
if(state[x + y * g_w] != (char)State::Lake)
return false;
state[x + y * g_w] = (char)State::Lake_Check;
if(x < (g_w - 1))
ChechLake(x + 1, y);
if(x > 0)
ChechLake(x - 1, y);
if(y < (g_h - 1))
ChechLake(x, y + 1);
if(y > 0)
ChechLake(x, y - 1);
return true;
}
int main()
{
std::cin >> g_h >> g_w;
char *s = new char[g_h * g_w];
state = s;
for(int i = 0; i < (g_h * g_w); i++)
{
int a;
std::cin >> a;
s[i] = (char)a;
}
int count = 0;
for(short y = 0; y < g_h; y++)
{
for(short x = 0; x < g_w; x++)
{
if(ChechLake(x, y))
count++;
}
}
std::cout << count << std::endl;
delete[] s;
return 0;
}
lunnear