結果

問題 No.2064 Smallest Sequence on Grid
ユーザー erbowlerbowl
提出日時 2022-09-04 16:20:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,022 bytes
コンパイル時間 2,474 ms
コンパイル使用メモリ 210,224 KB
実行使用メモリ 816,888 KB
最終ジャッジ日時 2024-04-29 16:44:18
合計ジャッジ時間 5,955 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 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 #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll h,w;
    std::cin >> h>>w;
    vector<vector<pair<ll,ll>>> prev(h,vector<pair<ll,ll>>(w,{-1,-1}));
    vector<string> s(h);
    for (int i = 0; i < h; i++) {
        std::cin >> s[i];
    }
    vector<vector<pair<ll,ll>>> kou(h+w+3);
    kou[0].push_back({0,0});
    string ans = "";
    for (int i = 0; i < h+w-1; i++) {
        ll minc = 1000;
        for (auto e : kou[i]) {
            minc = min(minc, (ll)s[e.first][e.second]);
        }
        // std::cout << minc << std::endl;
        ans.push_back(minc);
        for (auto e : kou[i]) {
            if(s[e.first][e.second]==minc){
                if(e.first+1<h){
                    kou[i+1].push_back({e.first+1,e.second});
                }
                if(e.second+1<w){
                    kou[i+1].push_back({e.first,e.second+1});
                }
            }
        }
    }
    std::cout << ans << std::endl;
}
0