結果

問題 No.2064 Smallest Sequence on Grid
ユーザー erbowlerbowl
提出日時 2022-09-04 16:22:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,119 ms / 3,000 ms
コード長 932 bytes
コンパイル時間 2,261 ms
コンパイル使用メモリ 211,456 KB
実行使用メモリ 436,736 KB
最終ジャッジ日時 2024-04-29 16:47:44
合計ジャッジ時間 19,421 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 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 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 186 ms
15,488 KB
testcase_18 AC 186 ms
15,488 KB
testcase_19 AC 187 ms
15,488 KB
testcase_20 AC 1,538 ms
321,920 KB
testcase_21 AC 1,694 ms
347,904 KB
testcase_22 AC 1,176 ms
240,032 KB
testcase_23 AC 1,138 ms
226,304 KB
testcase_24 AC 1,177 ms
226,304 KB
testcase_25 AC 1,130 ms
226,432 KB
testcase_26 AC 2,119 ms
436,736 KB
testcase_27 AC 2,093 ms
436,736 KB
testcase_28 AC 189 ms
15,620 KB
testcase_29 AC 1,725 ms
369,536 KB
testcase_30 AC 170 ms
14,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef int 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<string> s(h);
    for (int i = 0; i < h; i++) {
        std::cin >> s[i];
    }
    vector<set<pair<ll,ll>>> kou(h+w+3);
    kou[0].insert({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].insert({e.first+1,e.second});
                }
                if(e.second+1<w){
                    kou[i+1].insert({e.first,e.second+1});
                }
            }
        }
    }
    std::cout << ans << std::endl;
}
0