Submission #17851

# Submission time Handle Problem Language Result Execution time Memory
17851 2016-01-12T13:36:14 Z Adilkhan K-th path (IZhO11_kthpath) C++
0 / 100
0 ms 2024 KB
#include <bits/stdc++.h>

#define pb push_back
#define endl "\n"
#define mp make_pair 
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define fname ""
#define sz(x) (int)(x.size())

typedef long long ll;

using namespace std;

const ll N = (ll)(5e5) + 322;
const ll INF = (ll)(1e9);
const ll mod = (ll)(1e9) + 7;
const double eps = 1e-9;

int n, m, k;

vector <string> v;

char ch[33][33];

void dfs(int x, int y, string s) {
  s += ch[x][y];
	if (x == n && y == m) {
		v.pb(s);
		return;
	}
	if (x + 1 <= n)
		dfs(x + 1, y, s);
	if (y + 1 <= m)	
		dfs(x, y + 1, s);
					
}

int main () {
	//freopen(fname".in", "r", stdin);
	//freopen(fname".out", "w", stdout);
	//cin >> n >> m;
	scanf("%lld%lld", &n, &m);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			scanf("%c", ch[i][j]);
		}
	}
	cin >> k;
	dfs(1, 1, "");
	sort(all(v));
	cout << v[k - 1];
	return 0;
}

Compilation message

kthpath.cpp: In function 'int main()':
kthpath.cpp:44:26: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
  scanf("%lld%lld", &n, &m);
                          ^
kthpath.cpp:44:26: warning: format '%lld' expects argument of type 'long long int*', but argument 3 has type 'int*' [-Wformat=]
kthpath.cpp:47:24: warning: format '%c' expects argument of type 'char*', but argument 2 has type 'int' [-Wformat=]
    scanf("%c", ch[i][j]);
                        ^
kthpath.cpp:44:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &n, &m);
                           ^
kthpath.cpp:47:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%c", ch[i][j]);
                         ^
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -