# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
200432 | 2020-02-06T19:55:41 Z | wilwxk | Journey (NOI18_journey) | C++14 | 103 ms | 35808 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 1e4+5; const int MAXM = 405; const ll MOD = 500000001LL; ll dp[MAXN][MAXM]; vector<pair<int, int> > g[MAXN]; int n, m, x; int main() { scanf("%d %d %d", &n, &m, &x); for(int i = 0; i < n-1; i ++) { for(int j = 0; j < x; j++) { int a, b; scanf("%d %d", &a, &b); if(a <= i) continue; g[a].push_back({i, b}); } } dp[0][0] = 1; for(int i = 1; i < n; i++) { for(int j = 0; j < m; j++) { for(auto edge : g[i]) { int k = j-edge.second; if(k < 0) continue; dp[i][j] += dp[edge.first][k]; if(dp[i][j] > MOD) break; } // printf("%d %d >> %lld\n", i, j, dp[i][j]); } for(int j = 1; j < m; j++) dp[i][j] += dp[i][j-1], dp[i][j] = min(dp[i][j], MOD+10); } for(int i = 0; i < m; i++) printf("%lld ", min(dp[n-1][i], MOD)); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 632 KB | Output is correct |
2 | Correct | 5 ms | 504 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 632 KB | Output is correct |
2 | Correct | 5 ms | 632 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 632 KB | Output is correct |
2 | Correct | 5 ms | 504 KB | Output is correct |
3 | Correct | 5 ms | 632 KB | Output is correct |
4 | Correct | 5 ms | 632 KB | Output is correct |
5 | Correct | 6 ms | 888 KB | Output is correct |
6 | Correct | 6 ms | 888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 632 KB | Output is correct |
2 | Correct | 5 ms | 504 KB | Output is correct |
3 | Correct | 5 ms | 632 KB | Output is correct |
4 | Correct | 5 ms | 632 KB | Output is correct |
5 | Correct | 6 ms | 888 KB | Output is correct |
6 | Correct | 6 ms | 888 KB | Output is correct |
7 | Correct | 103 ms | 35808 KB | Output is correct |
8 | Correct | 102 ms | 21880 KB | Output is correct |
9 | Correct | 24 ms | 3448 KB | Output is correct |
10 | Correct | 60 ms | 4856 KB | Output is correct |