Submission #397861

#TimeUsernameProblemLanguageResultExecution timeMemory
397861maomao90Journey (NOI18_journey)C++14
100 / 100
78 ms35488 KiB
#include <bits/stdc++.h> using namespace std; typedef pair <int, int> ii; #define INF 500000001 int n, m, h; vector <ii> adjList[10005]; long long memo[10005][405]; long long dp(int index, int rem) { if (index >= n - 1) { if (rem == 0) return 1; else return 0; } if (rem < 0) return 0; if (memo[index][rem] != -1) return memo[index][rem]; long long cur = 0; cur += dp(index, rem - 1); if (cur >= INF) return memo[index][rem] = INF; for (ii vw : adjList[index]) { int v, w; tie(v, w) = vw; cur += dp(v, rem - w); if (cur >= INF) return memo[index][rem] = INF; } return memo[index][rem] = cur; } int main() { scanf("%d%d%d", &n, &m, &h); for (int i = 0; i < n - 1; i++) { for (int jj = 0; jj < h; jj++) { int j, k; scanf("%d%d", &j, &k); if (j <= i) continue; adjList[i].emplace_back(j, k); } } memset(memo, -1, sizeof memo); for (int i = 0; i < m; i++) { printf("%lld ", dp(0, i)); } printf("\n"); return 0; }

Compilation message (stderr)

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