Submission #586434

#TimeUsernameProblemLanguageResultExecution timeMemory
586434M_WJourney (NOI18_journey)C++17
20 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define ii pair<int, int> using namespace std; const int md = 500000001; vector<ii> adj[505]; int dp[505][505]; int main(){ int N, M, H; scanf("%d %d %d", &N, &M, &H); for(int i = 1; i < N; i++){ for(int j = 1, u, w; j <= H; j++){ scanf("%d %d", &u, &w); adj[i].push_back({u + 1, w}); } } dp[1][0] = 1; for(int i = 1; i < N; i++){ for(int j = 0; j < M; j++){ if(j > 0) dp[i][j] = min(dp[i][j] + dp[i][j - 1], md); for(auto [x, w] : adj[i]){ dp[x][min(501, j + w)] += dp[i][j]; dp[x][min(501, j + w)] = min(dp[x][min(501, j + w)], md); } } } for(int i = 0; i < M; i++) printf("%d ", dp[N][i]); }

Compilation message (stderr)

journey.cpp: In function 'int main()':
journey.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  scanf("%d %d %d", &N, &M, &H);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
journey.cpp:12:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |    scanf("%d %d", &u, &w);
      |    ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...