結果

問題 No.2064 Smallest Sequence on Grid
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2022-09-02 22:22:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 919 ms / 3,000 ms
コード長 1,085 bytes
コンパイル時間 1,988 ms
コンパイル使用メモリ 212,304 KB
実行使用メモリ 12,568 KB
最終ジャッジ日時 2024-04-27 21:56:50
合計ジャッジ時間 12,556 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 417 ms
12,316 KB
testcase_18 AC 409 ms
12,328 KB
testcase_19 AC 417 ms
12,356 KB
testcase_20 AC 693 ms
12,520 KB
testcase_21 AC 730 ms
12,568 KB
testcase_22 AC 593 ms
12,320 KB
testcase_23 AC 669 ms
12,532 KB
testcase_24 AC 654 ms
12,504 KB
testcase_25 AC 648 ms
12,472 KB
testcase_26 AC 880 ms
12,460 KB
testcase_27 AC 919 ms
12,492 KB
testcase_28 AC 420 ms
12,292 KB
testcase_29 AC 719 ms
12,448 KB
testcase_30 AC 431 ms
11,864 KB
権限があれば一括ダウンロードができます

ソースコード

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();
        sort(X[fl].begin(), X[fl].end());
        auto result = std::unique(X[fl].begin(), X[fl].end());
        X[fl].erase(result, X[fl].end());
        for (auto x : X[fl]) {
            now.push_back(x);
        }
    }
    cout << endl;
}
0