# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168222 | itgl | K-th path (IZhO11_kthpath) | C++14 | 2 ms | 376 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;
int n,m,k;
int vis[35][35];
char a[35][35];
string ans;
int cnt=0;
bool ch=1;
void graph(int i,int j, string s) {
if(!ch) return;
if(i>=n||j>=m)return;
s+=a[i][j];
if(i==n-1&&j==m-1){
cnt++;
}
if(cnt==k&&ch){
ch=0;
ans=s;
return;
}
graph(i,j+1,s);
graph(i+1,j,s);
}
int main(){
cin >> n >> m;
string s;
for(int i=0;i<n;i++){
cin >> s;
for(int j=0;j<m;j++) a[i][j]=s[j];
}
cin >> k;
graph(0,0,"");
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |