結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー | shoshoshom |
提出日時 | 2022-09-02 23:20:48 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 824 bytes |
コンパイル時間 | 2,500 ms |
コンパイル使用メモリ | 215,936 KB |
実行使用メモリ | 340,928 KB |
最終ジャッジ日時 | 2024-04-27 23:02:20 |
合計ジャッジ時間 | 7,817 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
13,884 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 1 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 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,944 KB |
testcase_11 | TLE | - |
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 | -- | - |
ソースコード
#include <bits/stdc++.h> using namespace std; inline void min_self(long long &a, long long b) { if (b < a) { a = b; } } int main() { iostream::sync_with_stdio(0), cin.tie(0), cout.tie(0); int h, w; cin >> h >> w; vector<string> grid(h); for (int i = 0; i < h; i++) { cin >> grid[i]; } using P = pair<string, pair<int, int>>; priority_queue<P, vector<P>, greater<P>> que; auto Push = [&](string s, int i, int j) { que.push(make_pair(s, make_pair(i, j))); }; Push("", 0, 0); while (true) { auto [s, p] = que.top(); auto [i, j] = p; que.pop(); s += grid[i][j]; if (i == h - 1 && j == w - 1) { cout << s << '\n'; return 0; } if (i + 1 < h) { Push(s, i + 1, j); } if (j + 1 < w) { Push(s, i, j + 1); } } return 0; }