Submission #131525

#TimeUsernameProblemLanguageResultExecution timeMemory
131525Just_Solve_The_ProblemPinball (JOI14_pinball)C++11
11 / 100
2 ms504 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int maxn = (int)1e5 + 7; const int smalln = (int)1e3 + 7; int n, m; int a[maxn], b[maxn], c[maxn], d[maxn]; ll dp[smalln][smalln]; int pos[maxn]; ll go(int i1, int i2) { if (b[i2] == n) return 0; ll &res = dp[i1][i2]; if (res != (ll)1e18) return res; res = 1e18 - 1; for (int i = 0; i < m; i++) { if (i1 == i) continue; if (i < i1) { if (c[i] <= b[i2] && i < i2) { if (b[i] > b[i2]) { res = min(res, go(i1, i) + d[i]); } } } else { if (a[i] <= c[i1] && c[i1] <= b[i]) { if (b[i2] > b[i]) { res = min(res, go(i, i2) + d[i]); } else { res = min(res, go(i, i) + d[i]); } } } } return res; } main() { scanf("%d %d", &m, &n); iota(pos, pos + m, 0); for (int i = 0; i < m; i++) { scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]); } if (n >= smalln) return 0; if (n == 1) { puts("0"); return 0; } // work for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { dp[i][j] = 1e18; } } // find ans ll ans = 1e18; for (int i = 0; i < m; i++) if (a[i] == 1) ans = min(ans, go(i, i) + d[i]); if (ans == (ll)1e18) ans = -1; printf("%lld\n", ans); }

Compilation message (stderr)

pinball.cpp:41:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
pinball.cpp: In function 'int main()':
pinball.cpp:42:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &m, &n);
   ~~~~~^~~~~~~~~~~~~~~~~
pinball.cpp:45:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...