結果
問題 | No.2064 Smallest Sequence on Grid |
ユーザー | sui |
提出日時 | 2022-09-03 13:52:38 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,482 bytes |
コンパイル時間 | 4,075 ms |
コンパイル使用メモリ | 263,144 KB |
実行使用メモリ | 14,976 KB |
最終ジャッジ日時 | 2024-04-28 12:17:00 |
合計ジャッジ時間 | 10,506 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 170 ms
14,976 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | AC | 146 ms
14,976 KB |
testcase_30 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i < (int)(n+1); i++) #define repn(i,a,b) for (int i = (int)(a) ; i < (int)(b+1); i++) #define repv(i, n) for (int i = (int)(n-1); i >= 0; i--) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define sz(x) ((int)(x).size()) #define cauto const auto& #define bit(n) (1LL<<(n)) #define uni(v) v.erase( unique(v.begin(), v.end()), v.end() ); using ll = long long; using P = pair<int,int>; using PP = pair<int, P>; using Graph = vector<vector<int>>; using mint = modint998244353; #ifdef LOCAL #include <debug.hpp> #define debug(...) debug::multi_print(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) (static_cast<void>(0)) #endif int main(){ int h,w; cin >> h >> w; vector<string> s(h); rep(i,h) cin >> s[i]; int start_x = 0, start_y = 0; string ans = ""; auto dfs = [&](auto&& dfs, int x, int y) -> void { ans += s[y][x]; if(x == w-1 && y == h-1) return; if(x == w-1){ dfs(dfs, x, y+1); } else if(y == h-1){ dfs(dfs, x+1, y); } else { if(s[y][x+1] < s[y+1][x]){ dfs(dfs, x+1, y); } else { dfs(dfs, x, y+1); } } }; dfs(dfs, start_x, start_y); cout << ans << endl; return 0; }