結果

問題 No.2064 Smallest Sequence on Grid
コンテスト
ユーザー erbowl
提出日時 2022-09-04 16:20:24
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
MLE  
実行時間 -
コード長 1,022 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,338 ms
コンパイル使用メモリ 219,792 KB
実行使用メモリ 1,307,432 KB
最終ジャッジ日時 2026-06-27 12:30:14
合計ジャッジ時間 4,913 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 MLE * 2 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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