# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
586462 | 2022-06-30T09:51:16 Z | hibiki | Journey (NOI18_journey) | C++11 | 3 ms | 4564 KB |
#include<bits/stdc++.h> using namespace std; #define MX 500000001 #define pb push_back #define f first #define s second int n,m,h; vector<pair<int,int> > v[10005]; int dp[10005][105]; int ind[10005]; int main() { scanf("%d %d %d",&n,&m,&h); for(int i = 0; i < n - 1; i++) { for(int j = 0; j < h; j++) { int a,b; scanf("%d %d",&a,&b); if(i > a) continue; v[i].pb({a,b}); ind[a]++; } } memset(dp, 0, sizeof(dp)); dp[0][0] = 1; queue<int> q; q.push(0); while(!q.empty()) { int nw = q.front(); q.pop(); if(nw != 0) for(int i = 1; i < m; i++) { dp[nw][i] += dp[nw][i - 1]; if(dp[nw][i] > MX) dp[nw][i] = MX; } for(auto go: v[nw]) { ind[go.f]--; if(ind[go.f] == 0) q.push(go.f); for(int i = 0; i + go.s < m; i++) { dp[go.f][i + go.s] += dp[nw][i]; if(dp[go.f][i + go.s] > MX) dp[go.f][i + go.s] = MX; } } } for(int i = 0; i < m; i++) printf("%d ",dp[n - 1][i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4564 KB | Output is correct |
2 | Correct | 2 ms | 4564 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4564 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4564 KB | Output is correct |
2 | Correct | 2 ms | 4564 KB | Output is correct |
3 | Incorrect | 2 ms | 4564 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4564 KB | Output is correct |
2 | Correct | 2 ms | 4564 KB | Output is correct |
3 | Incorrect | 2 ms | 4564 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |