結果

問題 No.2064 Smallest Sequence on Grid
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2022-09-02 22:19:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 938 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 209,652 KB
実行使用メモリ 814,536 KB
最終ジャッジ日時 2024-04-27 21:54:56
合計ジャッジ時間 5,304 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
int main () {
    int H, W;
    cin >> H >> W;
    char A[3030][3030];
    for (int i = 0; i < H; i ++) {
        for (int j = 0; j < W; j ++) {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < H; i ++) {
        A[i][W] = '{';
    }
    for (int j = 0; j < W; j ++) {
        A[H][j] = '{';
    }
    vector<P> now = {P{0, 0}};
    cout << A[0][0];
    string key = "abcdefghijklmnopqrstuvwxyz";
    for (int i = 2; i < H + W; i ++) {
        std::vector<P> X[50];
        for (auto [x, y] : now) {
            X[A[x + 1][y] - 'a'].emplace_back(x + 1, y);
            X[A[x][y + 1] - 'a'].emplace_back(x, y + 1);
        }
        int fl = 0;
        while (X[fl].empty()) {
            fl ++;
        }
        cout << key[fl];
        now.clear();
        for (auto x : X[fl]) {
            now.push_back(x);
        }
    }
    cout << endl;
}
0