結果
| 問題 |
No.2064 Smallest Sequence on Grid
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-02 23:20:48 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 824 bytes |
| コンパイル時間 | 2,128 ms |
| コンパイル使用メモリ | 207,808 KB |
| 最終ジャッジ日時 | 2025-02-07 01:54:12 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 TLE * 15 MLE * 6 |
ソースコード
#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;
}