제출 #1137071

#제출 시각아이디문제언어결과실행 시간메모리
1137071lopkusK번째 경로 (IZhO11_kthpath)C++20
0 / 100
885 ms327680 KiB
#include <bits/stdc++.h> #define int long long using namespace std; int n, m, k; char a[35][35]; vector<string> all; void dfs(int x, int y, string c) { if(x == n && y == m) { all.push_back(c); return; } if(x + 1 <= n ) { dfs(x + 1, y, c + a[x + 1][y]); } if(y + 1 <= m) { dfs(x, y + 1, c + a[x][y + 1]); } } signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cin >> a[i][j]; } } cin >> k; string u = ""; u += a[1][1]; dfs(1, 1, u); sort(all.begin(), all.end()); cout << all[k - 1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...