結果
| 問題 |
No.2064 Smallest Sequence on Grid
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-05-05 19:36:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,134 bytes |
| コンパイル時間 | 1,265 ms |
| コンパイル使用メモリ | 120,792 KB |
| 最終ジャッジ日時 | 2025-02-12 17:19:36 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 7 TLE * 9 MLE * 13 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
using namespace std;
int main(){
int H, W, h, w, nh, nw;
char mc;
string ans="";
cin >> H >> W;
vector<string> S(H);
int dx[2] = {1, 0};
int dy[2] = {0, 1};
vector<pair<int, int>> v;
for (int i=0; i < H; i++) cin >> S[i];
ans += S[0][0];
v.push_back({0, 0});
for (int i=1; i<H+W-1; i++){
vector<tuple<char, int, int>> c;
for (auto [h, w] : v){
for (int dir=0; dir < 2; dir++){
nh = h + dx[dir];
nw = w + dy[dir];
if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
c.push_back({S[nh][nw], nh, nw});
}
}
v.clear();
sort(c.begin(), c.end());
tie(mc, h, w) = c[0];
ans += mc;
for (auto [cc, h, w] : c){
if (cc == mc) v.push_back({h, w});
}
}
cout << ans << endl;
return 0;
}
srjywrdnprkt