結果
問題 | No.697 池の数はいくつか |
ユーザー | fine |
提出日時 | 2018-09-28 10:59:34 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 803 bytes |
コンパイル時間 | 1,510 ms |
コンパイル使用メモリ | 163,320 KB |
実行使用メモリ | 574,824 KB |
最終ジャッジ日時 | 2024-04-25 20:19:35 |
合計ジャッジ時間 | 8,813 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,944 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 1 ms
6,948 KB |
testcase_13 | AC | 2 ms
6,940 KB |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | AC | 1 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 1 ms
6,944 KB |
testcase_18 | AC | 1 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 1 ms
6,940 KB |
testcase_22 | AC | 1 ms
6,940 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | AC | 79 ms
6,944 KB |
testcase_25 | AC | 81 ms
7,952 KB |
testcase_26 | AC | 81 ms
7,160 KB |
testcase_27 | AC | 84 ms
6,944 KB |
testcase_28 | AC | 80 ms
7,444 KB |
testcase_29 | MLE | - |
testcase_30 | AC | 689 ms
12,440 KB |
testcase_31 | MLE | - |
testcase_32 | AC | 697 ms
12,368 KB |
testcase_33 | AC | 695 ms
12,240 KB |
testcase_34 | AC | 695 ms
12,396 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int dh[] = {1, -1, 0, 0}; const int dw[] = {0, 0, 1, -1}; bool f[3005][3005]; void dfs(int ch, int cw) { f[ch][cw] = false; for (int i = 0; i < 4; i++) { int nh = ch + dh[i], nw = cw + dw[i]; if (!f[nh][nw]) continue; dfs(nh, nw); } } int main() { cin.tie(0); ios::sync_with_stdio(false); int H, W; cin >> H >> W; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { cin >> f[i][j]; } } int ans = 0; for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { if (f[i][j]) { dfs(i, j); ans++; } } } cout << ans << endl; return 0; }