# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973340 | MvKaio | Pohlepko (COCI16_pohlepko) | C++17 | 1016 ms | 65536 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]);
vector<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;
vector<pair<int, int>> next_layer;
for (auto [i, j] : layer) {
if (i + 1 < n && grid[i + 1][j] == mn) {
next_layer.emplace_back(i + 1, j);
}
if (j + 1 < m && grid[i][j + 1] == mn) {
next_layer.emplace_back(i, j + 1);
}
}
layer = next_layer;
}
cout << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |