結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
![]() |
提出日時 | 2022-09-02 22:27:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,066 bytes |
コンパイル時間 | 1,403 ms |
コンパイル使用メモリ | 102,464 KB |
実行使用メモリ | 814,840 KB |
最終ジャッジ日時 | 2024-11-16 04:24:21 |
合計ジャッジ時間 | 26,151 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 MLE * 14 |
ソースコード
#include <iostream> #include <string> #include <algorithm> #include <math.h> #include <vector> #include <map> #include <set> #include <deque> #include <queue> #include <cstdio> #include <iomanip> #include <list> #define PI 3.14159265358979323846 #define mod 1000000007 #define pow9 1000000000 #define INF (1 << 30) using namespace std; int main() { int h, w; cin >> h >> w; vector<vector<char>> s(h, vector<char>(w)); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cin >> s[i][j]; } } vector<string> ans(h * w + 1); ans[1] = s[0][0]; for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { if (i == 0 && j == 0) continue; else if (i == 0) { ans[i * w + j + 1] = ans[i * w + j] + s[i][j]; } else if (j == 0) { ans[i * w + j + 1] = ans[(i - 1) * w + j + 1] + s[i][j]; } else if (ans[(i - 1) * w + j + 1] >= ans[i * w + j]) { ans[i * w + j + 1] = ans[i * w + j] + s[i][j]; } else { ans[i * w + j + 1] = ans[(i - 1) * w + j + 1] + s[i][j]; } } } cout << ans[h * w] << endl; }