結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
![]() |
提出日時 | 2022-09-02 21:40:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 899 bytes |
コンパイル時間 | 1,007 ms |
コンパイル使用メモリ | 102,384 KB |
実行使用メモリ | 54,540 KB |
最終ジャッジ日時 | 2024-11-16 02:47:59 |
合計ジャッジ時間 | 59,077 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 TLE * 14 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <map> #include <queue> #include <set> #include <random> using namespace std; typedef long long ll; #define rep(i, n) for(int i = 0; i < (n); i++) template<class T> using vi = vector<T>; template<class T> using vii = vector<vi<T>>; template<class T> using viii = vector<vii<T>>; int main() { int h, w; cin >> h >> w; vi<string> s(h); rep(i, h) cin >> s[i]; vi<string> dp(w); dp[0] = s[0][0]; for (int j = 1; j < w; j++) dp[j] = dp[j - 1] + s[0][j]; for(int i = 1; i < h; i++) { vi<string> prev(w); swap(prev, dp); dp[0] = prev[0] + s[i][0]; for (int j = 1; j < w; j++) { dp[j] = dp[j - 1] + s[i][j]; string temp = prev[j] + s[i][j]; if (temp < dp[j]) dp[j] = temp; } } cout << dp[w - 1] << endl; return 0; }