| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 973342 | MvKaio | Pohlepko (COCI16_pohlepko) | C++17 | 62 ms | 7004 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
int main() {
fast_io;
int n, m;
cin >> n >> m;
vector<string> grid(n);
for (auto &x : grid) cin >> x;
string ans(1, grid[0][0]);
set<pair<int, int>> layer = {{0, 0}};
for (int it = 1; it < n + m - 1; it++) {
char mn = 'z';
for (auto [i, j] : layer) {
if (i + 1 < n) {
mn = min(mn, grid[i + 1][j]);
}
if (j + 1 < m) {
mn = min(mn, grid[i][j + 1]);
}
}
ans += mn;
set<pair<int, int>> next_layer;
for (auto [i, j] : layer) {
if (i + 1 < n && grid[i + 1][j] == mn) {
next_layer.emplace(i + 1, j);
}
if (j + 1 < m && grid[i][j + 1] == mn) {
next_layer.emplace(i, j + 1);
}
}
layer = next_layer;
}
cout << ans << endl;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
