Submission #168222

# Submission time Handle Problem Language Result Execution time Memory
168222 2019-12-12T03:05:08 Z itgl K-th path (IZhO11_kthpath) C++14
0 / 100
2 ms 376 KB
#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
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 -