結果

問題 No.2064 Smallest Sequence on Grid
ユーザー shojin_proshojin_pro
提出日時 2022-09-02 22:13:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 918 bytes
コンパイル時間 1,017 ms
コンパイル使用メモリ 88,132 KB
実行使用メモリ 549,984 KB
最終ジャッジ日時 2024-04-27 21:47:55
合計ジャッジ時間 6,681 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,760 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 MLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
using namespace std;
int main(void){
    int H,W;
    cin >> H >> W;
    vector<string> map(H);
    for(int i = 0; i < H; i++){
        cin >> map[i];
    }
    priority_queue<
        pair<string,int>,     
        vector<pair<string,int>>,
        greater<pair<string,int>>
    > que;
    string vv{map[0][0]};
    que.push(make_pair(vv,0));
    while(!que.empty()){
        pair<string,int> v = que.top();
        que.pop();
        //cout << v.first << " " << v.second << endl;
        int h = v.second / 3001;
        int w = v.second % 3001;
        if(h+1 == H && w+1 == W){
            cout << v.first << endl;
            return 0;
        }
        if(w+1 != W){
            que.push(make_pair(string(v.first+map[h][w+1]),v.second+1));
        }
        if(h+1 != H){
            que.push(make_pair(string(v.first+map[h+1][w]),v.second+3001));
        }
        
    }
}
0