結果
問題 | No.340 雪の足跡 |
ユーザー | りあん |
提出日時 | 2016-02-09 03:07:01 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 254 ms / 1,000 ms |
コード長 | 1,630 bytes |
コンパイル時間 | 3,225 ms |
コンパイル使用メモリ | 164,368 KB |
実行使用メモリ | 31,160 KB |
最終ジャッジ日時 | 2023-10-21 20:30:24 |
合計ジャッジ時間 | 6,917 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
9,948 KB |
testcase_01 | AC | 3 ms
9,948 KB |
testcase_02 | AC | 3 ms
9,948 KB |
testcase_03 | AC | 4 ms
9,948 KB |
testcase_04 | AC | 3 ms
9,948 KB |
testcase_05 | AC | 3 ms
9,948 KB |
testcase_06 | AC | 3 ms
9,948 KB |
testcase_07 | AC | 3 ms
9,948 KB |
testcase_08 | AC | 3 ms
9,948 KB |
testcase_09 | AC | 3 ms
9,948 KB |
testcase_10 | AC | 3 ms
9,948 KB |
testcase_11 | AC | 4 ms
9,956 KB |
testcase_12 | AC | 4 ms
9,964 KB |
testcase_13 | AC | 4 ms
9,976 KB |
testcase_14 | AC | 12 ms
10,524 KB |
testcase_15 | AC | 14 ms
10,552 KB |
testcase_16 | AC | 11 ms
10,224 KB |
testcase_17 | AC | 17 ms
14,712 KB |
testcase_18 | AC | 15 ms
14,712 KB |
testcase_19 | AC | 18 ms
14,712 KB |
testcase_20 | AC | 144 ms
30,564 KB |
testcase_21 | AC | 91 ms
9,952 KB |
testcase_22 | AC | 20 ms
24,344 KB |
testcase_23 | AC | 151 ms
30,836 KB |
testcase_24 | AC | 129 ms
26,400 KB |
testcase_25 | AC | 141 ms
30,740 KB |
testcase_26 | AC | 23 ms
10,036 KB |
testcase_27 | AC | 7 ms
9,948 KB |
testcase_28 | AC | 20 ms
10,304 KB |
testcase_29 | AC | 185 ms
22,904 KB |
testcase_30 | AC | 119 ms
20,856 KB |
testcase_31 | AC | 206 ms
31,100 KB |
testcase_32 | AC | 254 ms
31,160 KB |
testcase_33 | AC | 194 ms
31,160 KB |
testcase_34 | AC | 245 ms
31,160 KB |
testcase_35 | AC | 156 ms
30,840 KB |
testcase_36 | AC | 159 ms
30,840 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d%d%d", &w, &h, &n); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d", &m); | ~~~~~^~~~~~~~~~ main.cpp:14:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d", &b[j]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; #define LM 1000000 int l[LM][4], dist[LM], th[LM][2]; int main(){ int w, h, n; scanf("%d%d%d", &w, &h, &n); for (int i = 1; i < LM; ++i) dist[i] = LM; for (int i = 0; i < n; ++i){ int m, b[1001]; scanf("%d", &m); for (int j = 0; j < m + 1; ++j){ scanf("%d", &b[j]); if (!j) continue; int sm = min(b[j], b[j - 1]); int la = max(b[j], b[j - 1]); ++th[sm][la - sm < w]; --th[la][la - sm < w]; } } for (int i = 0; i < w; ++i){ int sum = 0; for (int j = i; j < w * h; j += w) l[j][0] = l[j + w][2] = (sum += th[j][0]) > 0; } for (int i = 0; i < w * h; i += w){ int sum = 0; for (int j = i; j < w + i; ++j) l[j][1] = l[j + 1][3] = (sum += th[j][1]) > 0; } queue<int> q; q.push(0); while (!q.empty()){ int p = q.front(); q.pop(); if (p == w * h - 1) break; int pd = dist[p] + 1; if (l[p][0] && dist[p + w] > pd){ dist[p + w] = pd; q.push(p + w); } if (l[p][1] && dist[p + 1] > pd){ dist[p + 1] = pd; q.push(p + 1); } if (l[p][2] && dist[p - w] > pd){ dist[p - w] = pd; q.push(p - w); } if (l[p][3] && dist[p - 1] > pd){ dist[p - 1] = pd; q.push(p - 1); } } if (dist[w * h - 1] >= LM) printf("Odekakedekinai..\n"); else printf("%d\n", dist[w * h - 1]); }