結果

問題 No.2064 Smallest Sequence on Grid
ユーザー Manuel1024Manuel1024
提出日時 2023-09-11 05:38:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 610 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 73,564 KB
実行使用メモリ 814,508 KB
最終ジャッジ日時 2023-09-11 05:38:27
合計ジャッジ時間 4,344 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 4 ms
4,432 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 4 ms
4,588 KB
testcase_14 AC 4 ms
4,684 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 MLE -
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 <vector>
#include <string>
using namespace std;

int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h);
    for(auto &it: s) cin >> it;

    vector<vector<string>> dp(h, vector<string>(w, "{}"));
    dp[h-1][w-1] = s[h-1][w-1];
    for(int i = h-1; i >= 0; i--){
        for(int j = w-1; j >= 0; j--){
            if(i+1 < h){
                dp[i][j] = min(dp[i][j], s[i][j]+dp[i+1][j]);
                dp[i+1][j].clear();
            }
            if(j+1 < w) dp[i][j] = min(dp[i][j], s[i][j]+dp[i][j+1]);
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}
0