結果
問題 | No.5006 Hidden Maze |
ユーザー | Haa |
提出日時 | 2022-06-12 16:42:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 151 ms / 2,000 ms |
コード長 | 3,390 bytes |
コンパイル時間 | 1,759 ms |
実行使用メモリ | 22,864 KB |
スコア | 82,298 |
平均クエリ数 | 178.02 |
最終ジャッジ日時 | 2022-06-12 16:43:04 |
合計ジャッジ時間 | 10,287 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
21,892 KB |
testcase_01 | AC | 28 ms
22,276 KB |
testcase_02 | AC | 28 ms
21,928 KB |
testcase_03 | AC | 23 ms
21,992 KB |
testcase_04 | AC | 42 ms
21,756 KB |
testcase_05 | AC | 59 ms
22,216 KB |
testcase_06 | AC | 23 ms
21,928 KB |
testcase_07 | AC | 92 ms
21,952 KB |
testcase_08 | AC | 91 ms
21,940 KB |
testcase_09 | AC | 42 ms
21,904 KB |
testcase_10 | AC | 26 ms
22,216 KB |
testcase_11 | AC | 25 ms
22,276 KB |
testcase_12 | AC | 35 ms
21,940 KB |
testcase_13 | AC | 26 ms
21,780 KB |
testcase_14 | AC | 27 ms
21,928 KB |
testcase_15 | AC | 23 ms
22,600 KB |
testcase_16 | AC | 37 ms
21,992 KB |
testcase_17 | AC | 21 ms
21,952 KB |
testcase_18 | AC | 38 ms
21,892 KB |
testcase_19 | AC | 45 ms
21,992 KB |
testcase_20 | AC | 43 ms
21,916 KB |
testcase_21 | AC | 33 ms
21,916 KB |
testcase_22 | AC | 26 ms
22,276 KB |
testcase_23 | AC | 28 ms
21,952 KB |
testcase_24 | AC | 24 ms
22,456 KB |
testcase_25 | AC | 33 ms
21,904 KB |
testcase_26 | AC | 144 ms
22,288 KB |
testcase_27 | AC | 58 ms
21,880 KB |
testcase_28 | AC | 19 ms
21,964 KB |
testcase_29 | AC | 144 ms
21,940 KB |
testcase_30 | AC | 26 ms
21,892 KB |
testcase_31 | AC | 27 ms
21,928 KB |
testcase_32 | AC | 36 ms
22,576 KB |
testcase_33 | AC | 29 ms
22,468 KB |
testcase_34 | AC | 37 ms
22,016 KB |
testcase_35 | AC | 27 ms
21,892 KB |
testcase_36 | AC | 29 ms
21,952 KB |
testcase_37 | AC | 30 ms
21,892 KB |
testcase_38 | AC | 23 ms
22,228 KB |
testcase_39 | AC | 29 ms
22,632 KB |
testcase_40 | AC | 27 ms
22,564 KB |
testcase_41 | AC | 31 ms
21,928 KB |
testcase_42 | AC | 55 ms
21,588 KB |
testcase_43 | AC | 26 ms
21,940 KB |
testcase_44 | AC | 20 ms
21,768 KB |
testcase_45 | AC | 62 ms
21,780 KB |
testcase_46 | AC | 143 ms
22,264 KB |
testcase_47 | AC | 35 ms
21,780 KB |
testcase_48 | AC | 30 ms
22,240 KB |
testcase_49 | AC | 115 ms
22,204 KB |
testcase_50 | AC | 22 ms
21,928 KB |
testcase_51 | AC | 24 ms
22,632 KB |
testcase_52 | AC | 34 ms
22,704 KB |
testcase_53 | AC | 37 ms
22,216 KB |
testcase_54 | AC | 24 ms
21,992 KB |
testcase_55 | AC | 47 ms
22,004 KB |
testcase_56 | AC | 26 ms
22,228 KB |
testcase_57 | AC | 48 ms
21,992 KB |
testcase_58 | AC | 25 ms
21,892 KB |
testcase_59 | AC | 116 ms
21,780 KB |
testcase_60 | AC | 27 ms
21,780 KB |
testcase_61 | AC | 22 ms
21,780 KB |
testcase_62 | AC | 36 ms
21,892 KB |
testcase_63 | AC | 23 ms
21,756 KB |
testcase_64 | AC | 31 ms
21,768 KB |
testcase_65 | AC | 22 ms
22,216 KB |
testcase_66 | AC | 21 ms
21,952 KB |
testcase_67 | AC | 28 ms
21,928 KB |
testcase_68 | AC | 59 ms
22,028 KB |
testcase_69 | AC | 21 ms
21,992 KB |
testcase_70 | AC | 22 ms
22,576 KB |
testcase_71 | AC | 26 ms
21,780 KB |
testcase_72 | AC | 23 ms
21,928 KB |
testcase_73 | AC | 77 ms
21,768 KB |
testcase_74 | AC | 23 ms
21,964 KB |
testcase_75 | AC | 113 ms
21,940 KB |
testcase_76 | AC | 34 ms
21,892 KB |
testcase_77 | AC | 151 ms
21,792 KB |
testcase_78 | AC | 30 ms
21,940 KB |
testcase_79 | AC | 50 ms
22,228 KB |
testcase_80 | AC | 27 ms
22,864 KB |
testcase_81 | AC | 23 ms
21,904 KB |
testcase_82 | AC | 21 ms
22,216 KB |
testcase_83 | AC | 20 ms
21,780 KB |
testcase_84 | AC | 40 ms
22,456 KB |
testcase_85 | AC | 34 ms
21,940 KB |
testcase_86 | AC | 19 ms
21,916 KB |
testcase_87 | AC | 35 ms
21,880 KB |
testcase_88 | AC | 31 ms
21,992 KB |
testcase_89 | AC | 148 ms
21,904 KB |
testcase_90 | AC | 29 ms
22,588 KB |
testcase_91 | AC | 26 ms
21,952 KB |
testcase_92 | AC | 45 ms
22,600 KB |
testcase_93 | AC | 21 ms
21,904 KB |
testcase_94 | AC | 71 ms
21,940 KB |
testcase_95 | AC | 52 ms
21,904 KB |
testcase_96 | AC | 21 ms
21,768 KB |
testcase_97 | AC | 72 ms
21,904 KB |
testcase_98 | AC | 67 ms
21,780 KB |
testcase_99 | AC | 27 ms
21,880 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) v.begin(),v.end() template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;}; template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;}; const int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1}; const string dir="RDLU"; map<char,int> rid={{'R',0},{'D',1},{'L',2},{'U',3}}; int H, W, P; VI rea(20*20,0); VVI wall(20*20,VI(20*20,1)); inline int id(int x, int y){ return x*W+y; } double Uniform(){ return ((double)rand()+1.0)/((double)RAND_MAX+2.0); } double nom(double mu, double sigma){ double z=sqrt(-2.0*log(Uniform()))*sin(2.0*M_PI*Uniform()); return mu+sigma*z; } string newroute(){ VI pre(H*W,-1); pre[id(0,0)]=-2; queue<pair<int,int>> que, sque; que.push({0,0}); vector<pair<int,int>> ps; while(!que.empty()){ int x=que.front().first; int y=que.front().second; que.pop(); VI perm={0,1,2,3}; random_shuffle(ALL(perm)); REP(i,4){ int tx=x+dx[perm[i]]; int ty=y+dy[perm[i]]; if(tx<0||tx>=H||ty<0||ty>=W) continue; if(pre[id(tx,ty)]!=-1) continue; if(rea[id(tx,ty)]){ if(!wall[id(x,y)][id(tx,ty)]){ pre[id(tx,ty)]=perm[i]; que.push({tx,ty}); } } else if(wall[id(x,y)][id(tx,ty)]<abs(nom(0,0.5))*P){ pre[id(tx,ty)]=perm[i]; ps.push_back({tx,ty}); } } } random_shuffle(ALL(ps)); for(auto p:ps) sque.push(p); while(!sque.empty()){ int x=sque.front().first; int y=sque.front().second; sque.pop(); VI perm={0,1,2,3}; random_shuffle(ALL(perm)); REP(i,4){ int tx=x+dx[perm[i]]; int ty=y+dy[perm[i]]; if(tx<0||tx>=H||ty<0||ty>=W) continue; if(pre[id(tx,ty)]!=-1) continue; if(!rea[id(tx,ty)]&&wall[id(x,y)][id(tx,ty)]<abs(nom(0,0.5))*P){ pre[id(tx,ty)]=perm[i]; sque.push({tx,ty}); } } } int px=H-1, py=W-1; if(pre[id(px,py)]==-1) return ""; string ret=""; while(px!=0||py!=0){ int p=pre[id(px,py)]; ret+=dir[p]; px-=dx[p]; py-=dy[p]; } reverse(ALL(ret)); return ret; } void solve(){ rea[id(0,0)]=1; cin >> H >> W >> P; int X; REP(i,1001){ string s; REP(j,10){ s=newroute(); if(s.size()!=0) break; } if(s.size()==0){ REP(j,W-1) s+='R'; REP(j,H-1) s+='D'; } cout << s << endl; cin >> X; if(X==-1) break; int px=0, py=0; REP(j,X+1){ int npx=px+dx[rid[s[j]]]; int npy=py+dy[rid[s[j]]]; if(j<X){ wall[id(px,py)][id(npx,npy)]=0; rea[id(npx,npy)]=1; } else if(wall[id(px,py)][id(npx,npy)]!=0){ wall[id(px,py)][id(npx,npy)]++; } px=npx; py=npy; } } } int main(){ solve(); return 0; }