Submission #963202

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
9632022024-04-14 17:30:22biankK-th path (IZhO11_kthpath)C++14
0 / 100
1 ms460 KiB
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 30;
using ll = long long;
ll dp[MAX_N][MAX_N][2];
char g[MAX_N][MAX_N];
ll ways(int n, int m, string &s) { //maneras de llegar de 0, 0 a n - 1, m - 1 con camino <= s
memset(dp, 0, sizeof dp);
dp[0][0][g[0][0] != s[0]] = 1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (i != 0) {
dp[i][j][1] += dp[i - 1][j][1];
if (g[i][j] <= s[i + j]) {
dp[i][j][g[i][j] != s[i + j]] += dp[i - 1][j][0];
}
}
if (j != 0) {
dp[i][j][1] += dp[i][j - 1][1];
if (g[i][j] <= s[i + j]) {
dp[i][j][g[i][j] != s[i + j]] += dp[i][j - 1][0];
}
}
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...