結果
| 問題 | No.2064 Smallest Sequence on Grid |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-02 23:07:26 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 656 bytes |
| 記録 | |
| コンパイル時間 | 1,314 ms |
| コンパイル使用メモリ | 215,720 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-27 11:57:44 |
| 合計ジャッジ時間 | 7,706 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 15 TLE * 1 -- * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
inline void min_self(string &a, string &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];
}
vector<string> dp(w, "{");
dp[0] = "";
for (int i = 0; i < h; i++) {
vector<string> ndp(w, "{");
for (int j = 0; j < w; j++) {
string nst = dp[j] + grid[i][j];
min_self(ndp[j], nst);
if (j + 1 < w) {
min_self(dp[j + 1], nst);
}
}
swap(dp, ndp);
}
cout << dp[w - 1] << '\n';
return 0;
}