結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
|
提出日時 | 2024-04-13 17:31:55 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 855 bytes |
コンパイル時間 | 4,584 ms |
コンパイル使用メモリ | 258,516 KB |
最終ジャッジ日時 | 2025-02-21 01:11:58 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 3 WA * 3 MLE * 1 -- * 22 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using ld = long double; using mint = modint998244353; int main() { int H, W; cin >> H >> W; vector<string> S(H); for (int i = 0; i < H; i++) cin >> S[i]; string ans = string(H * W - 1, 'z'); queue<pair<int, string>> que; string s = string(1, S[0][0]); que.push({0, s}); int dx[2] = {1, 0}; int dy[2] = {0, 1}; while (!que.empty()) { auto &[id, t] = que.front(); que.pop(); int x = id / W; int y = id % W; if (x == H - 1 && y == W - 1) { ans = min(ans, t); continue; } for (int i = 0; i < 2; i++) { int nx = x + dx[i]; int ny = y + dy[i]; if (nx >= H || ny >= W) continue; que.push({nx * W + ny, t + S[nx][ny]}); } } cout << ans << endl; return 0; }