結果
| 問題 |
No.2064 Smallest Sequence on Grid
|
| コンテスト | |
| ユーザー |
koryou
|
| 提出日時 | 2022-09-03 15:30:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 2,567 bytes |
| コンパイル時間 | 1,203 ms |
| コンパイル使用メモリ | 118,292 KB |
| 最終ジャッジ日時 | 2025-02-07 02:22:58 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 10 TLE * 4 MLE * 15 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
#include <list>
#include <cassert>
#include <numeric>
#include <cstdint>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <random>
#include <bitset>
// #include <atcoder/all>
using ll = long long;
using ld = long double;
using namespace std;
// using namespace atcoder;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
using Priority = priority_queue<ll, vector<ll>, greater<ll>>;// 昇順
using Priority_pair = priority_queue<P, vector<P>, greater<P>>;
// using mint_17 = modint1000000007;
// using mint = modint998244353;
#define mod 1000000007
#define MAX_WIDTH 60
#define MAX_HEIGHT 60
#define INF 1e18
#define MOD 998244353
#define PI 3.141592653589793
#define rep(i, a, b) for(ll i=(a);i<(b);i++)
#define rrep(i, a, b) for(ll i=(a);i>=(b);i--)
#define fore(i, a) for(auto &i: a)
#define all(v) (v).begin(), (v).end()
#define YES(a) cout << ((a) ? "YES" : "NO") << endl
#define Yes(a) cout << ((a) ? "Yes" : "No") << endl
#define pb(a) push_back(a)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vp vector<pair<ll, ll>>
#define mll map<ll, ll>
#define msl map<string, ll>
#define COUT(n) cout << (n) << endl
#define isInGrid(a, b, h, w) (0 <= (a) && (a) < (h) && 0 <= (b) && (b) < (w))
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int vx[] = {1, 0, -1, 0}, vy[] = {0, 1, 0, -1};
struct edge {
ll to, cost;
};
ll H, W;
char S[3010][3010];
int main() {
cin >> H >> W;
rep(i,0,H) {
rep(j,0,W) {
cin >> S[i][j];
}
}
string ans;
ans += S[0][0];
vector<P> p = {P(0,0)};
rep(i,0,H+W-2) {
vector<P> nxt;
for(auto j: p) {
ll h = j.first, w = j.second;
if(h+1 < H) {
nxt.push_back(P(h+1, w));
}
if(w+1 < W) {
nxt.push_back(P(h, w+1));
}
}
char mn = 'z';
for(auto j: nxt) {
if(mn > S[j.first][j.second]) {
mn = S[j.first][j.second];
}
}
ans += mn;
p.clear();
for(auto j: nxt) {
if(S[j.first][j.second] == mn) {
p.push_back(j);
}
}
}
COUT(ans);
return 0;
}
koryou