# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
656830 | TheEvilBird | K-th path (IZhO11_kthpath) | C++17 | 522 ms | 262144 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 all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)((x).size())
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
//typedef __int128_t int128;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const char en = '\n';
const int INF = 1e9 + 7;
const ll INFLL = 1e18;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#ifdef __APPLE__
#include "debug.h"
//#define debug(...) 42
#else
#define debug(...) 42
#endif
const pii go[2] = {
{1, 0},
{0, 1}
};
int n, m;
vector<string> grid, s;
string cur;
bool in(int x, int y) {
return 0 <= x && x < n && 0 <= y && y < m;
}
void dfs(int x, int y) {
cur += grid[x][y];
if (x == n - 1 && y == m - 1) {
s.emplace_back(cur);
return;
}
for (auto [dx, dy]: go) {
int nx = x + dx, ny = y + dy;
if (in(nx, ny)) {
dfs(nx, ny);
cur.pop_back();
}
}
}
void solve() {
cin >> n >> m;
grid.resize(n);
for (int i = 0; i < n; ++i) {
cin >> grid[i];
}
dfs(0, 0);
sort(all(s));
ll k;
cin >> k;
cout << s[k - 1] << en;
}
int main() {
#ifdef __APPLE__
freopen("input.txt", "r", stdin);
#else
ios_base::sync_with_stdio(0);
cin.tie(0);
#endif
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |