Submission #656830

#TimeUsernameProblemLanguageResultExecution timeMemory
656830TheEvilBirdK-th path (IZhO11_kthpath)C++17
0 / 100
522 ms262144 KiB
#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 timeMemoryGrader output
Fetching results...