結果
| 問題 | No.2064 Smallest Sequence on Grid |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-13 17:31:55 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 855 bytes |
| 記録 | |
| コンパイル時間 | 2,934 ms |
| コンパイル使用メモリ | 283,872 KB |
| 実行使用メモリ | 1,301,296 KB |
| 最終ジャッジ日時 | 2026-07-04 11:38:37 |
| 合計ジャッジ時間 | 7,323 ms |
|
ジャッジサーバーID (参考情報) |
temp-judge_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 3 WA * 3 MLE * 2 -- * 21 |
ソースコード
#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;
}