結果

問題 No.2064 Smallest Sequence on Grid
ユーザー shojin_pro
提出日時 2022-09-02 22:13:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 918 bytes
コンパイル時間 1,189 ms
コンパイル使用メモリ 86,832 KB
最終ジャッジ日時 2025-02-07 01:24:28
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 MLE * 1
other AC * 6 TLE * 7 MLE * 16
権限があれば一括ダウンロードができます

ソースコード

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