結果
問題 | No.5006 Hidden Maze |
ユーザー | merom686 |
提出日時 | 2022-06-12 15:45:15 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 111 ms / 2,000 ms |
コード長 | 3,639 bytes |
コンパイル時間 | 2,233 ms |
実行使用メモリ | 22,876 KB |
スコア | 73,303 |
平均クエリ数 | 267.97 |
最終ジャッジ日時 | 2022-06-12 15:46:07 |
合計ジャッジ時間 | 10,619 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
21,892 KB |
testcase_01 | AC | 28 ms
21,792 KB |
testcase_02 | AC | 20 ms
21,904 KB |
testcase_03 | AC | 27 ms
22,408 KB |
testcase_04 | AC | 34 ms
22,612 KB |
testcase_05 | AC | 58 ms
21,916 KB |
testcase_06 | AC | 26 ms
21,796 KB |
testcase_07 | AC | 96 ms
21,964 KB |
testcase_08 | AC | 98 ms
21,928 KB |
testcase_09 | AC | 100 ms
21,904 KB |
testcase_10 | AC | 25 ms
22,588 KB |
testcase_11 | AC | 27 ms
22,624 KB |
testcase_12 | AC | 24 ms
21,904 KB |
testcase_13 | AC | 27 ms
22,456 KB |
testcase_14 | AC | 40 ms
21,892 KB |
testcase_15 | AC | 27 ms
21,928 KB |
testcase_16 | AC | 19 ms
22,444 KB |
testcase_17 | AC | 32 ms
22,004 KB |
testcase_18 | AC | 45 ms
22,564 KB |
testcase_19 | AC | 28 ms
21,780 KB |
testcase_20 | AC | 22 ms
21,980 KB |
testcase_21 | AC | 21 ms
21,892 KB |
testcase_22 | AC | 23 ms
22,876 KB |
testcase_23 | AC | 24 ms
21,916 KB |
testcase_24 | AC | 40 ms
21,952 KB |
testcase_25 | AC | 37 ms
22,548 KB |
testcase_26 | AC | 102 ms
22,612 KB |
testcase_27 | AC | 68 ms
22,716 KB |
testcase_28 | AC | 28 ms
21,892 KB |
testcase_29 | AC | 94 ms
21,992 KB |
testcase_30 | AC | 22 ms
22,004 KB |
testcase_31 | AC | 25 ms
21,792 KB |
testcase_32 | AC | 48 ms
21,904 KB |
testcase_33 | AC | 22 ms
21,904 KB |
testcase_34 | AC | 19 ms
21,952 KB |
testcase_35 | AC | 29 ms
22,560 KB |
testcase_36 | AC | 41 ms
22,624 KB |
testcase_37 | AC | 89 ms
21,904 KB |
testcase_38 | AC | 73 ms
21,904 KB |
testcase_39 | AC | 39 ms
21,904 KB |
testcase_40 | AC | 20 ms
21,768 KB |
testcase_41 | AC | 20 ms
21,952 KB |
testcase_42 | AC | 22 ms
22,204 KB |
testcase_43 | AC | 26 ms
21,904 KB |
testcase_44 | AC | 21 ms
22,240 KB |
testcase_45 | AC | 30 ms
22,216 KB |
testcase_46 | AC | 101 ms
22,560 KB |
testcase_47 | AC | 48 ms
21,780 KB |
testcase_48 | AC | 33 ms
22,072 KB |
testcase_49 | AC | 94 ms
21,940 KB |
testcase_50 | AC | 21 ms
22,600 KB |
testcase_51 | AC | 42 ms
21,940 KB |
testcase_52 | AC | 27 ms
22,420 KB |
testcase_53 | AC | 41 ms
21,892 KB |
testcase_54 | AC | 21 ms
22,612 KB |
testcase_55 | AC | 22 ms
21,780 KB |
testcase_56 | AC | 32 ms
22,240 KB |
testcase_57 | AC | 38 ms
21,780 KB |
testcase_58 | AC | 36 ms
22,048 KB |
testcase_59 | AC | 20 ms
22,240 KB |
testcase_60 | AC | 19 ms
21,784 KB |
testcase_61 | AC | 18 ms
21,940 KB |
testcase_62 | AC | 30 ms
22,456 KB |
testcase_63 | AC | 32 ms
22,420 KB |
testcase_64 | AC | 23 ms
22,600 KB |
testcase_65 | AC | 35 ms
21,968 KB |
testcase_66 | AC | 24 ms
21,952 KB |
testcase_67 | AC | 42 ms
22,252 KB |
testcase_68 | AC | 69 ms
22,588 KB |
testcase_69 | AC | 72 ms
21,968 KB |
testcase_70 | AC | 19 ms
22,016 KB |
testcase_71 | AC | 21 ms
22,264 KB |
testcase_72 | AC | 21 ms
21,916 KB |
testcase_73 | AC | 38 ms
21,780 KB |
testcase_74 | AC | 48 ms
21,904 KB |
testcase_75 | AC | 47 ms
22,004 KB |
testcase_76 | AC | 19 ms
22,192 KB |
testcase_77 | AC | 93 ms
22,576 KB |
testcase_78 | AC | 22 ms
21,904 KB |
testcase_79 | AC | 67 ms
22,576 KB |
testcase_80 | AC | 19 ms
22,372 KB |
testcase_81 | AC | 22 ms
22,204 KB |
testcase_82 | AC | 25 ms
21,836 KB |
testcase_83 | AC | 18 ms
22,572 KB |
testcase_84 | AC | 54 ms
21,780 KB |
testcase_85 | AC | 39 ms
21,952 KB |
testcase_86 | AC | 19 ms
22,004 KB |
testcase_87 | AC | 32 ms
21,980 KB |
testcase_88 | AC | 98 ms
22,288 KB |
testcase_89 | AC | 111 ms
22,576 KB |
testcase_90 | AC | 22 ms
21,940 KB |
testcase_91 | AC | 23 ms
22,588 KB |
testcase_92 | AC | 22 ms
22,624 KB |
testcase_93 | AC | 34 ms
22,004 KB |
testcase_94 | AC | 52 ms
21,940 KB |
testcase_95 | AC | 22 ms
22,600 KB |
testcase_96 | AC | 20 ms
21,940 KB |
testcase_97 | AC | 31 ms
21,952 KB |
testcase_98 | AC | 82 ms
21,904 KB |
testcase_99 | AC | 35 ms
21,768 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; }; double c0[N][N]; double 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] = 0.2; } } int l = 0; while (1) { l++; auto u = [&](double t) { if (l < 50) t = t + (1 - t) * p / 100; t = 1 - t; t = -log(t) * 1e6; return (int)clamp(t, 0.0, 1e9); }; 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, u(c0[i][j])); g.add_edge(k + 1, k, u(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, u(c1[i][j])); g.add_edge(k + N, k, u(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 = [&](double &c, int y) { if (y == 0) { c = 0; } else { if (c > 0) c = c / ((1 - c) * p / 100 + c); } }; 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; }