結果
問題 | No.5015 Escape from Labyrinth |
ユーザー | kaede2020 |
提出日時 | 2023-04-16 17:13:41 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,875 bytes |
コンパイル時間 | 2,268 ms |
コンパイル使用メモリ | 182,032 KB |
実行使用メモリ | 4,496 KB |
スコア | 29,090 |
最終ジャッジ日時 | 2023-04-16 17:18:03 |
合計ジャッジ時間 | 105,351 ms |
ジャッジサーバーID (参考情報) |
judge16 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,564 ms
4,368 KB |
testcase_01 | AC | 2,564 ms
4,372 KB |
testcase_02 | AC | 2,565 ms
4,372 KB |
testcase_03 | AC | 2,516 ms
4,372 KB |
testcase_04 | AC | 2,517 ms
4,368 KB |
testcase_05 | AC | 2,518 ms
4,368 KB |
testcase_06 | AC | 2,517 ms
4,368 KB |
testcase_07 | AC | 2,516 ms
4,368 KB |
testcase_08 | AC | 2,516 ms
4,372 KB |
testcase_09 | AC | 2,518 ms
4,368 KB |
testcase_10 | AC | 2,518 ms
4,368 KB |
testcase_11 | AC | 2,515 ms
4,368 KB |
testcase_12 | AC | 2,515 ms
4,372 KB |
testcase_13 | AC | 2,541 ms
4,372 KB |
testcase_14 | WA | - |
testcase_15 | AC | 2,517 ms
4,368 KB |
testcase_16 | AC | 2,540 ms
4,368 KB |
testcase_17 | AC | 2,540 ms
4,368 KB |
testcase_18 | AC | 2,515 ms
4,368 KB |
testcase_19 | AC | 2,516 ms
4,368 KB |
testcase_20 | AC | 2,516 ms
4,372 KB |
testcase_21 | AC | 2,520 ms
4,372 KB |
testcase_22 | AC | 2,516 ms
4,372 KB |
testcase_23 | AC | 2,516 ms
4,368 KB |
testcase_24 | WA | - |
testcase_25 | AC | 2,516 ms
4,372 KB |
testcase_26 | AC | 2,517 ms
4,368 KB |
testcase_27 | AC | 2,515 ms
4,368 KB |
testcase_28 | AC | 2,517 ms
4,368 KB |
testcase_29 | AC | 2,516 ms
4,372 KB |
testcase_30 | AC | 2,515 ms
4,368 KB |
testcase_31 | AC | 2,517 ms
4,372 KB |
testcase_32 | AC | 2,542 ms
4,372 KB |
testcase_33 | AC | 2,517 ms
4,368 KB |
testcase_34 | WA | - |
testcase_35 | AC | 2,542 ms
4,372 KB |
testcase_36 | AC | 2,540 ms
4,368 KB |
testcase_37 | AC | 2,516 ms
4,368 KB |
testcase_38 | AC | 2,516 ms
4,376 KB |
testcase_39 | AC | 2,516 ms
4,372 KB |
testcase_40 | AC | 2,516 ms
4,368 KB |
testcase_41 | AC | 2,541 ms
4,372 KB |
testcase_42 | AC | 2,516 ms
4,372 KB |
testcase_43 | AC | 2,519 ms
4,376 KB |
testcase_44 | AC | 2,522 ms
4,372 KB |
testcase_45 | AC | 2,517 ms
4,372 KB |
testcase_46 | AC | 2,516 ms
4,368 KB |
testcase_47 | AC | 2,517 ms
4,372 KB |
testcase_48 | AC | 2,516 ms
4,368 KB |
testcase_49 | WA | - |
testcase_50 | AC | 2,516 ms
4,372 KB |
testcase_51 | AC | 2,516 ms
4,372 KB |
testcase_52 | AC | 2,543 ms
4,368 KB |
testcase_53 | AC | 2,518 ms
4,372 KB |
testcase_54 | AC | 2,515 ms
4,368 KB |
testcase_55 | AC | 2,517 ms
4,372 KB |
testcase_56 | AC | 2,523 ms
4,496 KB |
testcase_57 | AC | 2,517 ms
4,372 KB |
testcase_58 | WA | - |
testcase_59 | AC | 2,543 ms
4,368 KB |
testcase_60 | AC | 2,515 ms
4,368 KB |
testcase_61 | AC | 2,700 ms
4,376 KB |
testcase_62 | AC | 2,518 ms
4,368 KB |
testcase_63 | AC | 2,517 ms
4,372 KB |
testcase_64 | WA | - |
testcase_65 | AC | 2,516 ms
4,372 KB |
testcase_66 | AC | 2,516 ms
4,368 KB |
testcase_67 | AC | 2,518 ms
4,372 KB |
testcase_68 | AC | 2,527 ms
4,372 KB |
testcase_69 | AC | 2,518 ms
4,372 KB |
testcase_70 | AC | 2,517 ms
4,368 KB |
testcase_71 | AC | 2,517 ms
4,372 KB |
testcase_72 | AC | 2,519 ms
4,372 KB |
testcase_73 | AC | 2,516 ms
4,372 KB |
testcase_74 | AC | 2,519 ms
4,368 KB |
testcase_75 | AC | 2,517 ms
4,372 KB |
testcase_76 | AC | 2,517 ms
4,372 KB |
testcase_77 | AC | 2,517 ms
4,368 KB |
testcase_78 | AC | 2,517 ms
4,368 KB |
testcase_79 | AC | 2,521 ms
4,372 KB |
testcase_80 | AC | 2,516 ms
4,372 KB |
testcase_81 | AC | 2,518 ms
4,372 KB |
testcase_82 | AC | 2,542 ms
4,372 KB |
testcase_83 | AC | 2,517 ms
4,372 KB |
testcase_84 | AC | 2,541 ms
4,372 KB |
testcase_85 | AC | 2,515 ms
4,372 KB |
testcase_86 | AC | 2,515 ms
4,372 KB |
testcase_87 | AC | 2,517 ms
4,372 KB |
testcase_88 | AC | 2,516 ms
4,376 KB |
testcase_89 | AC | 2,518 ms
4,368 KB |
testcase_90 | AC | 2,516 ms
4,372 KB |
testcase_91 | AC | 2,520 ms
4,372 KB |
testcase_92 | AC | 2,516 ms
4,372 KB |
testcase_93 | AC | 2,517 ms
4,372 KB |
testcase_94 | AC | 2,541 ms
4,368 KB |
testcase_95 | AC | 2,517 ms
4,368 KB |
testcase_96 | AC | 2,517 ms
4,372 KB |
testcase_97 | AC | 2,516 ms
4,372 KB |
testcase_98 | AC | 2,517 ms
4,372 KB |
testcase_99 | AC | 2,517 ms
4,368 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:141:60: 警告: ‘gx’ may be used uninitialized [-Wmaybe-uninitialized] 141 | string goal = find_path(j2y, j2x, gy, gx, S); | ^ main.cpp:99:33: 備考: ‘gx’ はここで定義されています 99 | int sy, sx, ky, kx, gy, gx; | ^~ main.cpp:141:60: 警告: ‘gy’ may be used uninitialized [-Wmaybe-uninitialized] 141 | string goal = find_path(j2y, j2x, gy, gx, S); | ^ main.cpp:99:29: 備考: ‘gy’ はここで定義されています 99 | int sy, sx, ky, kx, gy, gx; | ^~ main.cpp:135:61: 警告: ‘kx’ may be used uninitialized [-Wmaybe-uninitialized] 135 | string another_point=find_path(ky,kx,jy,jx,S); | ^ main.cpp:99:25: 備考: ‘kx’ はここで定義されています 99 | int sy, sx, ky, kx, gy, gx; | ^~ main.cpp:135:61: 警告: ‘ky’ may be used uninitialized [-Wmaybe-uninitialized] 135 | string another_point=find_path(ky,kx,jy,jx,S); | ^ main.cpp:99:21: 備考: ‘ky’ はここで定義されています 99 | int sy, sx, ky, kx, gy, gx; | ^~ main.cpp:118:54: 警告: ‘sx’ may be used uninitialized [-Wmaybe-uninitialized] 118 | string find_key = find_path(sy, sx, ky, kx, S); | ^ main.cpp:99:17: 備考: ‘sx’ はここで定義されています 99 | int sy, sx, ky, kx, gy, gx; | ^~ main.cpp:118:54: 警告: ‘sy’ may be used uninitialized [-Wmaybe-uninitialized] 118 | string fi
ソースコード
#include <bits/stdc++.h> using namespace std; int RandInt(int a,int b){ return a+rand()%(b-a+1); } long long Seigenjikan=2500000;//実行時間1000000で1秒 long long time_s; clock_t endt,start; const int grid_size = 60; // 迷宮の大きさ const int max_hp = 1500; // 初期体力 //int dy[4] = {-1, 1, 0, 0}; //int dx[4] = {0, 0, -1, 1}; //string dir = "UDLR"; int dy[4] = {0, 1, 0, -1}; int dx[4] = {1, 0, -1, 0}; string dir = "ULDR"; // 探知機の情報 struct enemy{ int y, x, d, num; bool destroyed; enemy(int y, int x, int d, int num){ this->y = y, this->x = x, this->d = d; this-> num = num; destroyed = false; } }; // 範囲外かどうか bool range_out(int y, int x){ if(y < 0 || y >= grid_size) return true; if(x < 0 || x >= grid_size) return true; return false; } // BFSによる経路探索 string find_path(int sy, int sx, int gy, int gx, vector<string> &S){ int siz = S.size(); vector<vector<int>> dist(siz, vector<int>(siz, -1)); dist[sy][sx] = 0; queue<pair<int,int>> q; q.emplace(sy, sx); while(!q.empty()){ pair<int,int> p = q.front(); q.pop(); int y = p.first, x = p.second; for(int k = 0; k < 4; k++){ int ny = y + dy[k], nx = x + dx[k]; if(range_out(ny, nx)) continue; if(dist[ny][nx] != -1) continue; char cell = S[ny][nx]; if(cell == '#' || cell == 'B' || cell == 'E') continue; dist[ny][nx] = dist[y][x] + 1; q.emplace(ny, nx); } } string res; if(dist[gy][gx] == -1) return res; int now_y = gy, now_x = gx, now_d = dist[gy][gx]; while(now_y != sy || now_x != sx){ bool moved = false; for(int k = 0; k < 4; k++){ int new_y = now_y + dy[k], new_x = now_x + dx[k]; if(range_out(new_y, new_x)) continue; if(dist[new_y][new_x] != now_d - 1) continue; now_y = new_y, now_x = new_x; now_d--; //cerr<<"dir:"<<new_y<<" "<<new_x<<" "<<dir[k^1]<<" "<<dir[k]<<endl; //res.push_back(dir[k]); res.push_back(dir[k^1]); moved = true; break; } assert(moved); } reverse(res.begin(), res.end()); return res; } int main(){ start = clock(); // 入力の受け取り int N, D, H; cin >> N >> D >> H; vector<string> S(N); for(int i = 0; i < N; i++) cin >> S[i]; int M; cin >> M; vector<enemy> E; for(int i = 0; i < M; i++){ int y, x, d; cin >> y >> x >> d; E.emplace_back(y, x, d, i); } vector<pair<int,int>>jewl; string ans; int sy, sx, ky, kx, gy, gx; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ if(S[i][j] == 'S'){ sy = i, sx = j; //cerr<<"sy:"<<sy<<" sx:"<<sx<<endl; } else if(S[i][j] == 'K'){ ky = i, kx = j; } else if(S[i][j] == 'G'){ gy = i, gx = j; }else if(S[i][j] == 'J'){ jewl.emplace_back(make_pair(i,j)); } } } //初期解 // 鍵の取得 string find_key = find_path(sy, sx, ky, kx, S); ans += find_key; // 扉への移動 string goal = find_path(ky, kx, gy, gx, S); ans += goal; //時間内まわす長さ200以内なら採用 while(time_s<Seigenjikan){ string tmp_ans=find_key;//始点から鍵まで //ランダムな1点への移動 鍵からランダムな1点へ int r=RandInt(0,jewl.size()-1); int jy=jewl[r].first; int jx=jewl[r].second; int r2=RandInt(0,jewl.size()-1); while(r==r2)r2=RandInt(0,jewl.size()-1); int j2y=jewl[r2].first; int j2x=jewl[r2].second; string another_point=find_path(ky,kx,jy,jx,S); tmp_ans+=another_point; // ランダムな1点からランダムな1点への移動 string another_point2=find_path(jy,jx,j2y,j2x,S); tmp_ans+=another_point2; // ランダムな1点から扉への移動 string goal = find_path(j2y, j2x, gy, gx, S); tmp_ans += goal; if(tmp_ans.size()<300&&ans.size()<tmp_ans.size()){ ans=tmp_ans; } //時間を計測 endt = clock(); time_s = endt - start; } for(auto c : ans){ cout << "M " << c << endl; } return 0; }