#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |