結果
問題 | No.5006 Hidden Maze |
ユーザー | Haa |
提出日時 | 2022-06-12 16:49:10 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 271 ms / 2,000 ms |
コード長 | 3,390 bytes |
コンパイル時間 | 1,722 ms |
実行使用メモリ | 22,864 KB |
スコア | 76,630 |
平均クエリ数 | 234.70 |
最終ジャッジ日時 | 2022-06-12 16:49:23 |
合計ジャッジ時間 | 12,524 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge10 |
純コード判定しない問題か言語 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 190 ms
21,780 KB |
testcase_01 | AC | 56 ms
22,588 KB |
testcase_02 | AC | 34 ms
22,264 KB |
testcase_03 | AC | 29 ms
21,756 KB |
testcase_04 | AC | 40 ms
22,444 KB |
testcase_05 | AC | 79 ms
22,252 KB |
testcase_06 | AC | 30 ms
21,880 KB |
testcase_07 | AC | 32 ms
22,252 KB |
testcase_08 | AC | 48 ms
21,992 KB |
testcase_09 | AC | 26 ms
21,660 KB |
testcase_10 | AC | 106 ms
22,276 KB |
testcase_11 | AC | 100 ms
22,680 KB |
testcase_12 | AC | 44 ms
21,892 KB |
testcase_13 | AC | 45 ms
21,768 KB |
testcase_14 | AC | 59 ms
21,868 KB |
testcase_15 | AC | 21 ms
22,564 KB |
testcase_16 | AC | 25 ms
22,856 KB |
testcase_17 | AC | 20 ms
21,780 KB |
testcase_18 | AC | 41 ms
22,216 KB |
testcase_19 | AC | 48 ms
22,456 KB |
testcase_20 | AC | 66 ms
22,540 KB |
testcase_21 | AC | 53 ms
21,928 KB |
testcase_22 | AC | 59 ms
22,600 KB |
testcase_23 | AC | 36 ms
21,952 KB |
testcase_24 | AC | 50 ms
21,940 KB |
testcase_25 | AC | 35 ms
22,856 KB |
testcase_26 | AC | 88 ms
22,600 KB |
testcase_27 | AC | 46 ms
22,608 KB |
testcase_28 | AC | 24 ms
22,276 KB |
testcase_29 | AC | 177 ms
22,264 KB |
testcase_30 | AC | 271 ms
21,904 KB |
testcase_31 | AC | 47 ms
21,892 KB |
testcase_32 | AC | 59 ms
21,928 KB |
testcase_33 | AC | 56 ms
21,980 KB |
testcase_34 | AC | 27 ms
21,892 KB |
testcase_35 | AC | 41 ms
21,980 KB |
testcase_36 | AC | 23 ms
22,456 KB |
testcase_37 | AC | 77 ms
21,992 KB |
testcase_38 | AC | 24 ms
22,552 KB |
testcase_39 | AC | 28 ms
21,880 KB |
testcase_40 | AC | 94 ms
21,756 KB |
testcase_41 | AC | 85 ms
21,940 KB |
testcase_42 | AC | 45 ms
22,612 KB |
testcase_43 | AC | 51 ms
21,904 KB |
testcase_44 | AC | 24 ms
21,892 KB |
testcase_45 | AC | 62 ms
22,216 KB |
testcase_46 | AC | 189 ms
21,940 KB |
testcase_47 | AC | 26 ms
21,760 KB |
testcase_48 | AC | 24 ms
22,612 KB |
testcase_49 | AC | 103 ms
22,276 KB |
testcase_50 | AC | 66 ms
22,476 KB |
testcase_51 | AC | 152 ms
22,612 KB |
testcase_52 | AC | 70 ms
21,748 KB |
testcase_53 | AC | 54 ms
21,928 KB |
testcase_54 | AC | 38 ms
21,904 KB |
testcase_55 | AC | 31 ms
21,916 KB |
testcase_56 | AC | 38 ms
22,276 KB |
testcase_57 | AC | 69 ms
22,564 KB |
testcase_58 | AC | 28 ms
22,588 KB |
testcase_59 | AC | 36 ms
22,264 KB |
testcase_60 | AC | 173 ms
22,216 KB |
testcase_61 | AC | 21 ms
22,620 KB |
testcase_62 | AC | 59 ms
22,632 KB |
testcase_63 | AC | 47 ms
22,204 KB |
testcase_64 | AC | 41 ms
22,264 KB |
testcase_65 | AC | 27 ms
21,904 KB |
testcase_66 | AC | 48 ms
21,992 KB |
testcase_67 | AC | 22 ms
22,864 KB |
testcase_68 | AC | 53 ms
21,768 KB |
testcase_69 | AC | 26 ms
21,768 KB |
testcase_70 | AC | 89 ms
22,456 KB |
testcase_71 | AC | 40 ms
21,980 KB |
testcase_72 | AC | 27 ms
21,928 KB |
testcase_73 | AC | 81 ms
22,600 KB |
testcase_74 | AC | 26 ms
21,880 KB |
testcase_75 | AC | 50 ms
21,940 KB |
testcase_76 | AC | 27 ms
21,892 KB |
testcase_77 | AC | 100 ms
22,004 KB |
testcase_78 | AC | 29 ms
21,780 KB |
testcase_79 | AC | 45 ms
22,216 KB |
testcase_80 | AC | 76 ms
21,952 KB |
testcase_81 | AC | 80 ms
22,264 KB |
testcase_82 | AC | 41 ms
21,880 KB |
testcase_83 | AC | 26 ms
21,892 KB |
testcase_84 | AC | 50 ms
22,864 KB |
testcase_85 | AC | 43 ms
21,892 KB |
testcase_86 | AC | 21 ms
21,768 KB |
testcase_87 | AC | 35 ms
22,444 KB |
testcase_88 | AC | 33 ms
21,928 KB |
testcase_89 | AC | 170 ms
22,620 KB |
testcase_90 | AC | 65 ms
22,004 KB |
testcase_91 | AC | 109 ms
21,940 KB |
testcase_92 | AC | 80 ms
22,276 KB |
testcase_93 | AC | 29 ms
22,444 KB |
testcase_94 | AC | 34 ms
22,600 KB |
testcase_95 | AC | 23 ms
21,904 KB |
testcase_96 | AC | 22 ms
21,880 KB |
testcase_97 | AC | 123 ms
21,760 KB |
testcase_98 | AC | 70 ms
21,768 KB |
testcase_99 | AC | 23 ms
22,228 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.2))*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.2))*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; }