# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
246228 | 2020-07-08T11:57:39 Z | SamAnd | Journey (NOI18_journey) | C++17 | 171 ms | 25696 KB |
#include <bits/stdc++.h> using namespace std; #define m_p make_pair #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) #define fi first #define se second typedef long long ll; mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); mt19937 rnf(2106); const int N = 10004, M = 402, H = 102, U = 500000001; int n, m, q; pair<int, int> g[N][H]; int dp[N][M]; void solv() { scanf("%d%d%d", &n, &m, &q); for (int i = 0; i < n - 1; ++i) { for (int j = 0; j < q; ++j) scanf("%d%d", &g[i][j].fi, &g[i][j].se); } dp[0][0] = 1; for (int x = 0; x < n - 1; ++x) { for (int y = 1; y < m; ++y) { dp[x][y] += dp[x][y - 1]; dp[x][y] = min(dp[x][y], U); } for (int y = 0; y < m; ++y) { for (int i = 0; i < q; ++i) { int h = g[x][i].fi; int d = g[x][i].se; if (h <= x) continue; if (y + d < m) { dp[h][y + d] += dp[x][y]; dp[h][y + d] = min(dp[h][y + d], U); } } } } for (int y = 0; y < m; ++y) printf("%d ", dp[n - 1][y]); printf("\n"); } int main() { #ifdef SOMETHING freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); #endif // SOMETHING //ios_base::sync_with_stdio(false), cin.tie(0); solv(); return 0; } //while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 7 ms | 640 KB | Output is correct |
6 | Correct | 6 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 7 ms | 640 KB | Output is correct |
6 | Correct | 6 ms | 640 KB | Output is correct |
7 | Correct | 97 ms | 25696 KB | Output is correct |
8 | Correct | 110 ms | 15740 KB | Output is correct |
9 | Correct | 34 ms | 2304 KB | Output is correct |
10 | Correct | 171 ms | 2808 KB | Output is correct |