Submission #146970

#TimeUsernameProblemLanguageResultExecution timeMemory
146970gs14004Journey (NOI18_journey)C++17
100 / 100
217 ms10968 KiB
#include <bits/stdc++.h> #define sz(v) ((int)(v).size()) using namespace std; typedef long long lint; typedef pair<int, int> pi; const int MAXN = 10005; const int mod = 5e8 + 1; int n, m, h; vector<pi> nxt[MAXN]; int dp[405][MAXN]; int add[405][MAXN]; 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 x, y; scanf("%d %d",&x,&y); if(x > i){ nxt[i].emplace_back(x, y); } } } dp[0][0] = 1; for(int i=0; i<m; i++){ for(int j=0; j<n; j++){ add[i+1][j] = min(add[i+1][j] + add[i][j], mod); dp[i][j] = min(dp[i][j] + add[i][j], mod); for(auto &k : nxt[j]){ if(i + k.second < m){ add[i + k.second][k.first] = min(add[i + k.second][k.first] + dp[i][j], mod); } } } cout << dp[i][n-1] << " "; } }

Compilation message (stderr)

journey.cpp: In function 'int main()':
journey.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&m,&h);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
journey.cpp:18:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    int x, y; scanf("%d %d",&x,&y);
              ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...