結果
問題 | No.5006 Hidden Maze |
ユーザー | merom686 |
提出日時 | 2022-06-12 15:03:09 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 72 ms / 2,000 ms |
コード長 | 3,394 bytes |
コンパイル時間 | 3,052 ms |
実行使用メモリ | 22,704 KB |
スコア | 77,432 |
平均クエリ数 | 226.68 |
最終ジャッジ日時 | 2022-06-12 15:04:39 |
合計ジャッジ時間 | 8,964 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 21 ms
22,624 KB |
testcase_01 | AC | 20 ms
22,588 KB |
testcase_02 | AC | 18 ms
22,216 KB |
testcase_03 | AC | 18 ms
21,904 KB |
testcase_04 | AC | 21 ms
21,928 KB |
testcase_05 | AC | 20 ms
21,940 KB |
testcase_06 | AC | 21 ms
22,444 KB |
testcase_07 | AC | 51 ms
21,768 KB |
testcase_08 | AC | 61 ms
21,928 KB |
testcase_09 | AC | 59 ms
21,928 KB |
testcase_10 | AC | 19 ms
22,588 KB |
testcase_11 | AC | 18 ms
22,204 KB |
testcase_12 | AC | 23 ms
21,892 KB |
testcase_13 | AC | 19 ms
21,892 KB |
testcase_14 | AC | 46 ms
22,620 KB |
testcase_15 | AC | 24 ms
21,660 KB |
testcase_16 | AC | 18 ms
21,928 KB |
testcase_17 | AC | 20 ms
21,940 KB |
testcase_18 | AC | 28 ms
22,612 KB |
testcase_19 | AC | 20 ms
21,952 KB |
testcase_20 | AC | 18 ms
22,548 KB |
testcase_21 | AC | 20 ms
21,880 KB |
testcase_22 | AC | 23 ms
21,768 KB |
testcase_23 | AC | 24 ms
22,180 KB |
testcase_24 | AC | 22 ms
22,264 KB |
testcase_25 | AC | 20 ms
22,216 KB |
testcase_26 | AC | 30 ms
22,608 KB |
testcase_27 | AC | 20 ms
22,276 KB |
testcase_28 | AC | 22 ms
22,704 KB |
testcase_29 | AC | 40 ms
21,892 KB |
testcase_30 | AC | 20 ms
21,904 KB |
testcase_31 | AC | 18 ms
22,588 KB |
testcase_32 | AC | 25 ms
21,892 KB |
testcase_33 | AC | 23 ms
22,564 KB |
testcase_34 | AC | 19 ms
21,892 KB |
testcase_35 | AC | 30 ms
21,928 KB |
testcase_36 | AC | 47 ms
21,780 KB |
testcase_37 | AC | 60 ms
21,780 KB |
testcase_38 | AC | 17 ms
21,928 KB |
testcase_39 | AC | 21 ms
21,892 KB |
testcase_40 | AC | 18 ms
21,892 KB |
testcase_41 | AC | 19 ms
22,228 KB |
testcase_42 | AC | 24 ms
21,940 KB |
testcase_43 | AC | 26 ms
21,780 KB |
testcase_44 | AC | 19 ms
21,916 KB |
testcase_45 | AC | 23 ms
21,780 KB |
testcase_46 | AC | 23 ms
22,216 KB |
testcase_47 | AC | 37 ms
22,252 KB |
testcase_48 | AC | 35 ms
22,536 KB |
testcase_49 | AC | 72 ms
22,264 KB |
testcase_50 | AC | 20 ms
22,632 KB |
testcase_51 | AC | 21 ms
21,904 KB |
testcase_52 | AC | 23 ms
22,420 KB |
testcase_53 | AC | 27 ms
21,928 KB |
testcase_54 | AC | 19 ms
21,756 KB |
testcase_55 | AC | 25 ms
21,880 KB |
testcase_56 | AC | 38 ms
21,940 KB |
testcase_57 | AC | 43 ms
21,904 KB |
testcase_58 | AC | 53 ms
21,956 KB |
testcase_59 | AC | 21 ms
21,892 KB |
testcase_60 | AC | 20 ms
22,252 KB |
testcase_61 | AC | 18 ms
22,004 KB |
testcase_62 | AC | 20 ms
21,980 KB |
testcase_63 | AC | 22 ms
22,264 KB |
testcase_64 | AC | 29 ms
22,276 KB |
testcase_65 | AC | 22 ms
21,928 KB |
testcase_66 | AC | 27 ms
21,756 KB |
testcase_67 | AC | 30 ms
22,264 KB |
testcase_68 | AC | 44 ms
21,940 KB |
testcase_69 | AC | 32 ms
22,432 KB |
testcase_70 | AC | 20 ms
21,904 KB |
testcase_71 | AC | 19 ms
21,968 KB |
testcase_72 | AC | 20 ms
21,808 KB |
testcase_73 | AC | 27 ms
21,904 KB |
testcase_74 | AC | 26 ms
21,768 KB |
testcase_75 | AC | 40 ms
22,420 KB |
testcase_76 | AC | 18 ms
21,916 KB |
testcase_77 | AC | 53 ms
21,892 KB |
testcase_78 | AC | 32 ms
22,004 KB |
testcase_79 | AC | 63 ms
21,968 KB |
testcase_80 | AC | 18 ms
21,892 KB |
testcase_81 | AC | 23 ms
21,856 KB |
testcase_82 | AC | 23 ms
21,892 KB |
testcase_83 | AC | 20 ms
21,904 KB |
testcase_84 | AC | 21 ms
21,928 KB |
testcase_85 | AC | 36 ms
21,928 KB |
testcase_86 | AC | 22 ms
22,600 KB |
testcase_87 | AC | 26 ms
22,588 KB |
testcase_88 | AC | 39 ms
21,928 KB |
testcase_89 | AC | 33 ms
22,692 KB |
testcase_90 | AC | 20 ms
21,880 KB |
testcase_91 | AC | 20 ms
21,940 KB |
testcase_92 | AC | 20 ms
21,968 KB |
testcase_93 | AC | 19 ms
21,940 KB |
testcase_94 | AC | 29 ms
22,108 KB |
testcase_95 | AC | 33 ms
21,904 KB |
testcase_96 | AC | 18 ms
22,588 KB |
testcase_97 | AC | 63 ms
22,680 KB |
testcase_98 | AC | 72 ms
22,564 KB |
testcase_99 | AC | 28 ms
21,904 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int N = 20; struct Graph { static constexpr ll INF = 1LL << 60; struct VertexQ { bool operator<(const VertexQ &o) const { return c > o.c; // 逆 } int i; ll c; }; struct Vertex { int n; int d; ll c; }; struct Edge { int i, n, c; }; Graph(int n, int m) : v(n, { -1, -1, INF }), e(m), n(n), m(0) {} void add_edge(int a, int b, int c) { e[m] = { b, v[a].n, c }; v[a].n = m; m++; } void dijkstra(int i, int j) { for (int i = 0; i < n; i++) v[i].c = INF; priority_queue<VertexQ> q; q.push({ i, v[i].c = 0 }); while (!q.empty()) { auto p = q.top(); q.pop(); if (p.i == j) break; if (p.c > v[p.i].c) continue; for (int j = v[p.i].n; j >= 0; j = e[j].n) { Edge &o = e[j]; ll c = p.c + o.c; if (c < v[o.i].c) v[o.i].d = p.i, q.push({ o.i, v[o.i].c = c }); } } } vector<Vertex> v; vector<Edge> e; int n, m; }; int c0[N][N]; int c1[N][N]; int main() { int h, w, p; cin >> h >> w >> p; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { c0[i][j] = c1[i][j] = 1; } } while (1) { Graph g(N * N, N * N * 4); for (int i = 0; i < N; i++) { for (int j = 0; j < N - 1; j++) { int k = i * N + j; g.add_edge(k, k + 1, c0[i][j]); g.add_edge(k + 1, k, c0[i][j]); } } for (int i = 0; i < N - 1; i++) { for (int j = 0; j < N; j++) { int k = i * N + j; g.add_edge(k, k + N, c1[i][j]); g.add_edge(k + N, k, c1[i][j]); } } int k = N * N - 1; g.dijkstra(0, k); string s; vector<int> t; t.push_back(k); while (1) { int k1 = g.v[k].d; int d = k - k1; char x; if (d == 1) x = 'R'; else if (d == -1) x = 'L'; else if (d == N) x = 'D'; else x = 'U'; s.push_back(x); t.push_back(k1); k = k1; if (k == 0) break; } reverse(s.begin(), s.end()); reverse(t.begin(), t.end()); cout << s << endl; int a; cin >> a; if (a == -1) break; auto f = [&](int &c, int y) { if (y == 0) { c = 0; } else { if (c > 0 && c < (int)1e7) c = c * 100 / p; } }; for (int b = 0; b <= a; b++) { int k0 = t[b], k1 = t[b + 1]; if (k0 > k1) swap(k0, k1); int i = k0 / N, j = k0 % N; if (abs(k0 - k1) == 1) { f(c0[i][j], b == a); } else { f(c1[i][j], b == a); } } //for (int i = 0; i < N; i++) { // for (int j = 0; j < N - 1; j++) { // cout << c0[i][j] << ' '; // } // cout << '\n'; //} //for (int i = 0; i < N - 1; i++) { // for (int j = 0; j < N; j++) { // cout << c1[i][j] << ' '; // } // cout << '\n'; //} } return 0; }