結果
問題 |
No.5006 Hidden Maze
|
ユーザー |
|
提出日時 | 2022-06-12 17:40:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 4,684 bytes |
コンパイル時間 | 696 ms |
実行使用メモリ | 42,372 KB |
スコア | 0 |
最終ジャッジ日時 | 2022-06-12 17:40:58 |
合計ジャッジ時間 | 7,315 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 99 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cmath> #include <tuple> #include <bitset> #define rep(i,n) for(i=0; i<n; ++i) #define in(a) cin >> a #define out(a,b) cout << a << b using namespace std; using lint = long long; string set_width_fill(string str, int n, char c){ int w=n-str.size(); string filled=""; filled+=str; for(int i=0; i<w; ++i) filled+=c; return filled; } int main(void){ lint i, j; lint n, m; float p, add; in(n); in(n); in(p); add=(16-p)/2.0; vector<vector<float>> table(22,vector<float> (22,0)); rep(i,22) table[0][i]=100; rep(i,22) table[i][0]=100; rep(i,22) table[i][21]=100; rep(i,22) table[21][i]=100; bool init=true; int input=0, input_prev=0; int x=1, y=1; string s=""; while(1){ if(init){ s=set_width_fill(s,19,'R'); s=set_width_fill(s,38,'D'); init=false; } else {while(x<20&&y<20){ out(x," "); out(y,endl); int d=table[y+1][x], r=table[y][x+1], u=table[y-1][x], l=table[y][x-1]; if(s[s.size()-1]=='R'){ if(r==0){ s+='R'; x++; } else if(d==0){ s+='D'; y++; } else{ if(r<=d&&d<=u&&x<20){ s+='R'; x++; } else if(d<=r&&r<=u&&y<20){ s+='D'; y++; } else if(y>1){ s+='U'; y--; } } } else if(s[s.size()-1]=='D'){ if(d==0){ s+='D'; y++; } else if(r==0){ s+='R'; x++; } else{ if(r<=d&&d<=l&&x<20){ s+='R'; x++; } else if(d<=r&&r<=l&&y<20){ s+='D'; y++; } else if(x>1){ s+='L'; x--; } } } else if(s[s.size()-1]=='L'){ if(d==0){ s+='D'; y++; } else if(l==0){ s+='L'; x--; } else{ if(l<=d&&d<=u&&x>1){ s+='L'; x--; } else if(d<=u&&u<=l&&y<20){ s+='D'; y++; } else if(y>1){ s+='U'; y--; } } } else{ if(u==0){ s+='U'; y--; } else if(l==0){ s+='L'; x--; } else{ if(l<=r&&r<=u&&x>1){ s+='L'; x--; } else if(r<=u&&u<=l&&x<20){ s+='R'; x++; } else if(y>1){ s+='U'; y--; } } } table[y][x]++; } } if(x<16){ s+="UUUUU"; y-=5; } if(y<16){ s+="LLLLL"; x-=5; } out(s,flush); input_prev=input; in(input); if(input==-1) break; if(input_prev>input); else{ bool f=false; if(input!=s.size()) f=true; x=1, y=1; int cur=0; while(input){ if(s[cur]=='R'){ x++; } else if(s[cur]=='D'){ y++; } else if(s[cur]=='U'){ y--; } else{ x--; } table[y][x]--; input--; cur++; } if(f){ int tx=x, ty=y; if(s[cur]=='R'){ tx++; } else if(s[cur]=='D'){ ty++; } else if(s[cur]=='U'){ ty--; } else{ tx--; } if(table[ty][tx]>=0) table[ty][tx]+=add; } s.erase(cur, s.size()-cur); int a, b; rep(a,22){ rep(b,22){ out(table[a][b]," "); } out("",endl); } } } return 0; }