結果
問題 | No.5006 Hidden Maze |
ユーザー | highjump |
提出日時 | 2022-06-12 17:56:55 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 190 ms / 2,000 ms |
コード長 | 5,198 bytes |
コンパイル時間 | 1,866 ms |
実行使用メモリ | 22,876 KB |
スコア | 89,610 |
平均クエリ数 | 104.90 |
最終ジャッジ日時 | 2022-06-12 17:57:06 |
合計ジャッジ時間 | 10,780 ms |
ジャッジサーバーID (参考情報) |
judge10 / judge12 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
22,264 KB |
testcase_01 | AC | 33 ms
22,620 KB |
testcase_02 | AC | 32 ms
21,892 KB |
testcase_03 | AC | 29 ms
22,636 KB |
testcase_04 | AC | 26 ms
21,892 KB |
testcase_05 | AC | 52 ms
21,928 KB |
testcase_06 | AC | 27 ms
21,672 KB |
testcase_07 | AC | 29 ms
21,768 KB |
testcase_08 | AC | 66 ms
21,952 KB |
testcase_09 | AC | 26 ms
21,892 KB |
testcase_10 | AC | 25 ms
22,704 KB |
testcase_11 | AC | 24 ms
22,264 KB |
testcase_12 | AC | 38 ms
21,780 KB |
testcase_13 | AC | 36 ms
21,880 KB |
testcase_14 | AC | 34 ms
21,780 KB |
testcase_15 | AC | 28 ms
22,264 KB |
testcase_16 | AC | 22 ms
22,004 KB |
testcase_17 | AC | 29 ms
21,892 KB |
testcase_18 | AC | 48 ms
21,928 KB |
testcase_19 | AC | 23 ms
22,432 KB |
testcase_20 | AC | 27 ms
22,620 KB |
testcase_21 | AC | 22 ms
21,904 KB |
testcase_22 | AC | 28 ms
21,928 KB |
testcase_23 | AC | 43 ms
21,756 KB |
testcase_24 | AC | 43 ms
22,252 KB |
testcase_25 | AC | 28 ms
21,892 KB |
testcase_26 | AC | 79 ms
21,940 KB |
testcase_27 | AC | 32 ms
22,620 KB |
testcase_28 | AC | 25 ms
21,980 KB |
testcase_29 | AC | 68 ms
21,940 KB |
testcase_30 | AC | 24 ms
22,228 KB |
testcase_31 | AC | 23 ms
22,216 KB |
testcase_32 | AC | 47 ms
22,612 KB |
testcase_33 | AC | 34 ms
22,216 KB |
testcase_34 | AC | 29 ms
21,928 KB |
testcase_35 | AC | 42 ms
21,880 KB |
testcase_36 | AC | 35 ms
22,444 KB |
testcase_37 | AC | 58 ms
21,992 KB |
testcase_38 | AC | 30 ms
22,576 KB |
testcase_39 | AC | 32 ms
22,576 KB |
testcase_40 | AC | 25 ms
21,928 KB |
testcase_41 | AC | 32 ms
21,928 KB |
testcase_42 | AC | 50 ms
22,576 KB |
testcase_43 | AC | 34 ms
21,880 KB |
testcase_44 | AC | 26 ms
21,940 KB |
testcase_45 | AC | 44 ms
22,620 KB |
testcase_46 | AC | 132 ms
21,928 KB |
testcase_47 | AC | 27 ms
22,552 KB |
testcase_48 | AC | 45 ms
22,504 KB |
testcase_49 | AC | 70 ms
21,780 KB |
testcase_50 | AC | 24 ms
22,608 KB |
testcase_51 | AC | 26 ms
21,892 KB |
testcase_52 | AC | 45 ms
21,780 KB |
testcase_53 | AC | 55 ms
21,892 KB |
testcase_54 | AC | 30 ms
22,216 KB |
testcase_55 | AC | 28 ms
22,264 KB |
testcase_56 | AC | 42 ms
22,264 KB |
testcase_57 | AC | 50 ms
22,564 KB |
testcase_58 | AC | 31 ms
22,588 KB |
testcase_59 | AC | 25 ms
21,992 KB |
testcase_60 | AC | 29 ms
21,892 KB |
testcase_61 | AC | 28 ms
21,780 KB |
testcase_62 | AC | 27 ms
22,456 KB |
testcase_63 | AC | 26 ms
22,216 KB |
testcase_64 | AC | 50 ms
22,264 KB |
testcase_65 | AC | 45 ms
22,588 KB |
testcase_66 | AC | 29 ms
21,768 KB |
testcase_67 | AC | 35 ms
21,992 KB |
testcase_68 | AC | 43 ms
21,892 KB |
testcase_69 | AC | 35 ms
21,768 KB |
testcase_70 | AC | 24 ms
21,992 KB |
testcase_71 | AC | 25 ms
21,940 KB |
testcase_72 | AC | 24 ms
22,564 KB |
testcase_73 | AC | 29 ms
21,892 KB |
testcase_74 | AC | 26 ms
22,252 KB |
testcase_75 | AC | 44 ms
22,444 KB |
testcase_76 | AC | 26 ms
22,704 KB |
testcase_77 | AC | 42 ms
21,768 KB |
testcase_78 | AC | 46 ms
22,444 KB |
testcase_79 | AC | 166 ms
21,672 KB |
testcase_80 | AC | 28 ms
22,552 KB |
testcase_81 | AC | 30 ms
21,892 KB |
testcase_82 | AC | 32 ms
21,992 KB |
testcase_83 | AC | 24 ms
21,904 KB |
testcase_84 | AC | 41 ms
22,276 KB |
testcase_85 | AC | 45 ms
21,880 KB |
testcase_86 | AC | 24 ms
21,892 KB |
testcase_87 | AC | 27 ms
21,780 KB |
testcase_88 | AC | 34 ms
22,476 KB |
testcase_89 | AC | 190 ms
22,600 KB |
testcase_90 | AC | 29 ms
21,748 KB |
testcase_91 | AC | 24 ms
21,904 KB |
testcase_92 | AC | 47 ms
22,204 KB |
testcase_93 | AC | 26 ms
21,928 KB |
testcase_94 | AC | 30 ms
21,992 KB |
testcase_95 | AC | 26 ms
21,940 KB |
testcase_96 | AC | 23 ms
22,876 KB |
testcase_97 | AC | 40 ms
21,768 KB |
testcase_98 | AC | 77 ms
22,608 KB |
testcase_99 | AC | 42 ms
21,940 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int move(int, char)’ 内: main.cpp:132:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type] 132 | } | ^ main.cpp: 関数 ‘std::string findPath()’ 内: main.cpp:171:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type] 171 | } | ^
ソースコード
#pragma GCC optimize("Ofast") #include <iostream> #include <algorithm> #include <string> #include <cstdlib> #include <cmath> #include <iomanip> #include <cctype> #include <sstream> #include <vector> #include <stack> #include <deque> #include <queue> #include <list> #include <set> #include <map> #include <unordered_map> #include <chrono> #include <random> using namespace std; using ll = long long; using P = pair<int, int>; template <class T>using V = vector<T>; template <class T>using VV = V<V<T>>; template <class T, class U>bool chmin(T& t, const U& u) { if (t > u) { t = u; return 1; } else return 0; } template <class T, class U>bool chmax(T& t, const U& u) { if (t < u) { t = u; return 1; } else return 0; } #define REP(i,n) for(int i=0;i<int(n);i++) #define FOR(i,a,b) for(int i=int(a);i<=int(b);i++) #define FORD(i,a,b) for(int i=int(a);i>=int(b);i--) #define MP make_pair #define SZ(x) int(x.size()) #define ALL(x) x.begin(),x.end() #define INF 10001000 #define endl "\n" chrono::system_clock::time_point t_start; const double TIME_LIMIT1 = 500, TIME_LIMIT = 2930; double last_update = 0, t_diff; double start_temp, end_temp; mt19937 rng; using uni_int = uniform_int_distribution<>; using uni_real = uniform_real_distribution<>; using u64 = uint64_t; using u32 = uint32_t; V<int> y_vec = { 0, 1,0, -1 }; V<int> x_vec = { -1, 0,1, 0 }; class XorInt { public: uint32_t x = 2463534242; XorInt() {}; XorInt(uint32_t seed) { x = 2463534242 + seed; }; uint32_t next() { x ^= x << 13; x ^= x >> 17; x ^= x << 5; return x; } uint32_t operator()(uint32_t l, uint32_t r) { return (this->next() % (r - l)) + l; } uint32_t operator()(uint32_t d) { return this->next() % d; } }; XorInt xs=XorInt(20220612); class Xor64 { public: uint64_t x = 88172645463325252ULL; Xor64() {}; Xor64(uint64_t seed) { x = 88172645463325252ULL + seed; } uint64_t next() { x ^= x << 13; x ^= x >> 7; x ^= x << 17; return x; } uint64_t operator()(uint64_t l, uint64_t r) { return (this->next() % (r - l)) + l; } uint64_t operator()(uint64_t d) { return this->next() % d; } }; Xor64 xx; void get_time() { auto t_now = chrono::system_clock::now(); t_diff = chrono::duration_cast<chrono::milliseconds>(t_now - t_start).count(); } int H, W, p; int Pos(int x, int y) { return x * W + y; } char Dir(int pos, int npos) { if (pos / H == npos / H) { if (pos < npos)return'R'; else return 'L'; } else { if (pos < npos)return'D'; else return 'U'; } } int move(int pos, char dir) { if (dir == 'U')return pos - W; if (dir == 'R')return pos + 1; if (dir == 'D')return pos + W; if (dir == 'L')return pos - 1; } string Direction = "URDL"; VV<int> pass; class Cell { public: int state = 0; V<int> around4; Cell() {}; }; V<Cell> grid; string findPath() { int start = 0; int goal = H * W - 1; V<int> d(H * W, INF); V<string> path(H * W, ""); d[0] = 0; priority_queue<P, V<P>, greater<P>> pq; pq.push(MP(0, 0)); while (!pq.empty()) { int dis = pq.top().first; int pos = pq.top().second; pq.pop(); if (dis > d[pos])continue; if (pos == goal)return path[goal]; for (auto npos : grid[pos].around4) { int cost = max(0, pass[pos][npos]); if(pass[pos][npos]==0)cost += xs(1,(100-p)/2); if (chmin(d[npos], d[pos] + cost)) { path[npos] = path[pos] + Dir(pos,npos); pq.push(MP(d[npos], npos)); } } } } void update(string ans, int res) { int pos = 0; REP(i, res) { int npos = move(pos, ans[i]); pass[pos][npos] = -1; pass[npos][pos] = -1; pos = npos; } int npos = move(pos, ans[res]); if (pass[pos][npos] == -1)return; pass[pos][npos] += 100 - p; pass[npos][pos] = pass[pos][npos]; } signed main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); t_start = chrono::system_clock::now(); get_time(); cin >> H >> W >> p; grid = V<Cell>(H * W); pass = VV<int>(H * W, V<int>(H * W)); REP(x, H) { REP(y, W) { V<int> a; REP(k, 4) { int nx = x + x_vec[k]; int ny = y + y_vec[k]; if (nx < 0 || nx >= H || ny < 0 || ny >= W)continue; a.push_back(Pos(nx, ny)); } shuffle(ALL(a),rng); grid[Pos(x, y)].around4 = a; } } while (true) { string ans = findPath(); cerr << ans << endl; cout << ans << endl; cout.flush(); int res; cin >> res; if (res == -1)break; update(ans, res); } cerr << "time: " << int(t_diff) << " ms" << endl; //cerr << "score: " << score << endl; //cerr << "last: " << last_update << endl; //cerr << "cnt: " << cnt << endl; //cerr << "update:" << update_cnt << endl; return 0; }