結果
問題 | No.5006 Hidden Maze |
ユーザー | FplusFplusF |
提出日時 | 2022-06-12 17:54:18 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 79 ms / 2,000 ms |
コード長 | 2,351 bytes |
コンパイル時間 | 2,208 ms |
実行使用メモリ | 22,864 KB |
スコア | 18,299 |
平均クエリ数 | 818.01 |
最終ジャッジ日時 | 2022-06-12 17:54:31 |
合計ジャッジ時間 | 12,365 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 58 ms
21,916 KB |
testcase_01 | AC | 60 ms
22,264 KB |
testcase_02 | AC | 29 ms
21,904 KB |
testcase_03 | AC | 57 ms
21,928 KB |
testcase_04 | AC | 65 ms
22,576 KB |
testcase_05 | AC | 67 ms
21,940 KB |
testcase_06 | AC | 60 ms
22,588 KB |
testcase_07 | AC | 65 ms
22,288 KB |
testcase_08 | AC | 67 ms
21,904 KB |
testcase_09 | AC | 68 ms
22,564 KB |
testcase_10 | AC | 57 ms
22,704 KB |
testcase_11 | AC | 62 ms
21,992 KB |
testcase_12 | AC | 62 ms
21,928 KB |
testcase_13 | AC | 58 ms
21,780 KB |
testcase_14 | AC | 68 ms
21,928 KB |
testcase_15 | AC | 66 ms
21,780 KB |
testcase_16 | AC | 65 ms
22,216 KB |
testcase_17 | AC | 24 ms
22,216 KB |
testcase_18 | AC | 71 ms
22,540 KB |
testcase_19 | AC | 69 ms
21,768 KB |
testcase_20 | AC | 34 ms
22,204 KB |
testcase_21 | AC | 68 ms
22,264 KB |
testcase_22 | AC | 26 ms
21,928 KB |
testcase_23 | AC | 22 ms
22,564 KB |
testcase_24 | AC | 60 ms
21,940 KB |
testcase_25 | AC | 65 ms
21,992 KB |
testcase_26 | AC | 71 ms
22,264 KB |
testcase_27 | AC | 63 ms
22,576 KB |
testcase_28 | AC | 63 ms
22,264 KB |
testcase_29 | AC | 66 ms
21,768 KB |
testcase_30 | AC | 26 ms
22,384 KB |
testcase_31 | AC | 56 ms
22,704 KB |
testcase_32 | AC | 63 ms
21,892 KB |
testcase_33 | AC | 39 ms
21,880 KB |
testcase_34 | AC | 66 ms
22,216 KB |
testcase_35 | AC | 59 ms
22,432 KB |
testcase_36 | AC | 25 ms
22,576 KB |
testcase_37 | AC | 70 ms
22,432 KB |
testcase_38 | AC | 65 ms
21,992 KB |
testcase_39 | AC | 65 ms
21,904 KB |
testcase_40 | AC | 25 ms
21,756 KB |
testcase_41 | AC | 22 ms
21,768 KB |
testcase_42 | AC | 57 ms
21,780 KB |
testcase_43 | AC | 60 ms
21,940 KB |
testcase_44 | AC | 61 ms
21,748 KB |
testcase_45 | AC | 64 ms
22,132 KB |
testcase_46 | AC | 66 ms
21,892 KB |
testcase_47 | AC | 67 ms
22,264 KB |
testcase_48 | AC | 67 ms
21,928 KB |
testcase_49 | AC | 67 ms
22,612 KB |
testcase_50 | AC | 46 ms
21,780 KB |
testcase_51 | AC | 59 ms
21,904 KB |
testcase_52 | AC | 36 ms
21,980 KB |
testcase_53 | AC | 57 ms
21,992 KB |
testcase_54 | AC | 59 ms
21,768 KB |
testcase_55 | AC | 50 ms
22,456 KB |
testcase_56 | AC | 32 ms
22,432 KB |
testcase_57 | AC | 70 ms
21,892 KB |
testcase_58 | AC | 65 ms
22,600 KB |
testcase_59 | AC | 64 ms
22,204 KB |
testcase_60 | AC | 22 ms
22,264 KB |
testcase_61 | AC | 28 ms
22,456 KB |
testcase_62 | AC | 60 ms
22,204 KB |
testcase_63 | AC | 58 ms
21,992 KB |
testcase_64 | AC | 59 ms
22,216 KB |
testcase_65 | AC | 61 ms
21,952 KB |
testcase_66 | AC | 60 ms
22,204 KB |
testcase_67 | AC | 63 ms
22,612 KB |
testcase_68 | AC | 73 ms
21,904 KB |
testcase_69 | AC | 63 ms
21,940 KB |
testcase_70 | AC | 24 ms
21,768 KB |
testcase_71 | AC | 24 ms
22,444 KB |
testcase_72 | AC | 36 ms
21,892 KB |
testcase_73 | AC | 62 ms
21,768 KB |
testcase_74 | AC | 62 ms
22,276 KB |
testcase_75 | AC | 63 ms
22,600 KB |
testcase_76 | AC | 66 ms
22,704 KB |
testcase_77 | AC | 70 ms
21,780 KB |
testcase_78 | AC | 79 ms
22,588 KB |
testcase_79 | AC | 75 ms
21,928 KB |
testcase_80 | AC | 20 ms
22,456 KB |
testcase_81 | AC | 42 ms
21,768 KB |
testcase_82 | AC | 61 ms
21,780 KB |
testcase_83 | AC | 21 ms
22,252 KB |
testcase_84 | AC | 20 ms
22,588 KB |
testcase_85 | AC | 62 ms
21,904 KB |
testcase_86 | AC | 40 ms
22,864 KB |
testcase_87 | AC | 72 ms
21,928 KB |
testcase_88 | AC | 66 ms
21,928 KB |
testcase_89 | AC | 69 ms
21,892 KB |
testcase_90 | AC | 59 ms
21,756 KB |
testcase_91 | AC | 33 ms
22,444 KB |
testcase_92 | AC | 59 ms
22,528 KB |
testcase_93 | AC | 43 ms
21,892 KB |
testcase_94 | AC | 69 ms
21,892 KB |
testcase_95 | AC | 65 ms
22,608 KB |
testcase_96 | AC | 21 ms
21,980 KB |
testcase_97 | AC | 66 ms
21,980 KB |
testcase_98 | AC | 64 ms
21,768 KB |
testcase_99 | AC | 65 ms
22,228 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for (int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() using ll = long long; using pll = pair<ll, ll>; template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } } template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } } int main() { ll h, w; double p; cin >> h >> w >> p; srand((unsigned int)time(NULL)); vector<char> addc = { 'L','U','R','D' }; vector<vector<ll>> grid(h * w + 1); vector<ll> around = { -1,-h,1,w }; for (int i = 1; i <= h * w; i++) { rep(j, 4) { ll p = i + around[j]; if (i % h == 1 && j == 0) continue; if (i <= w && j == 1) continue; if (i % h == 0 && j == 2) continue; if (h * w - w < i && j == 3) continue; grid[i].push_back(p); } } map<ll, char> mp; mp[h] = 'D'; mp[1] = 'R'; mp[-1] = 'L'; mp[-h] = 'U'; map<char, ll> pd; pd['L'] = -1; pd['U'] = -h; pd['R'] = 1; pd['D'] = h; while (true) { vector<ll> dist(h * w + 1, -1); queue<ll> q; q.push(1); dist[1] = 0; while (!q.empty()) { ll x = q.front(); q.pop(); for (auto& i : grid[x]) { if (i == -1) continue; if (dist[i] == -1) { dist[i] = dist[x] + 1; q.push(i); } } } string root; vector<ll> rootv; rootv.push_back(h * w); ll dt = dist[h * w]; if (dt == -1) { grid.resize(h*w+1); for (int i = 1; i <= h * w; i++) { rep(j, 4) { ll p = i + around[j]; if (i % h == 1 && j == 0) continue; if (i <= w && j == 1) continue; if (i % h == 0 && j == 2) continue; if (h * w - w < i && j == 3) continue; grid[i].push_back(p); } } continue; } ll dtp = h * w; while (dt != 0) { for (auto& i : grid[dtp]) { if (i == -1) continue; if (dt == dist[i] + 1) { root.push_back(mp[dtp - i]); rootv.push_back(i); dt = dist[i]; dtp = i; break; } } } reverse(all(root)); reverse(all(rootv)); cout << root << endl; ll x = 0; cin >> x; if (x == -1) return 0; double k = 1; rep(i, x+1) { k *= 1-(p/100); } ll r = rand() % 101; if (r<=k*100) continue; for (auto& i : grid[rootv[x]]) { if (i == rootv[x] + pd[root[x]]) { i = -1; break; } } if (x + 1 != rootv.size()) { for (auto& i : grid[rootv[x + 1]]) { if (i == rootv[x]) { i = -1; break; } } } } }