Submission #962496

#TimeUsernameProblemLanguageResultExecution timeMemory
962496ErJRoller Coaster Railroad (IOI16_railroad)C++17
34 / 100
63 ms17112 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<ll> #define pp pair<ll, ll> #define inf 1000000000000000000 #define vvi vector<vi> #define vp vector<pp> #define vvp vector<vp> #define rep(i, n) for(int i = 0; i < n; i++) #define mod 1000000007 vvi dp; vi s, t; void find(ll a, ll b) { ll n = s.size(); ll akt = a; ll ak2 = 1; ll bx = pow(2, b); for (int i = 0; i < n; i++) { if ((akt % 2 == 1) && (i != b)) { dp[a][b] = min(dp[a][b], dp[a - bx][i] + max((ll) 0, t[i] - s[b])); } akt /= 2; } } ll plan_roller_coaster(vector<int> s1, vector<int> t1) { dp.clear(); s.clear(); t.clear(); ll n = s1.size(); s.resize(n); t.resize(n); rep(i, n) { s[i] = s1[i]; t[i] = t1[i]; } dp.resize(pow(2, n)); rep(i, dp.size()) { dp[i].resize(n); rep(j, n) { dp[i][j] = inf; } } rep(j, dp[0].size()) { dp[pow(2, j)][j] = 0; } rep(i, dp.size()) { ll akt = i; rep(j, n) { if (dp[i][j] == inf && (akt % 2 == 1)) { find(i, j); } akt /= 2; } } ll ans = inf; rep(i, dp[dp.size() - 1].size()) { ans = min(ans, dp[dp.size() - 1][i]); } return ans; }

Compilation message (stderr)

railroad.cpp: In function 'void find(long long int, long long int)':
railroad.cpp:21:8: warning: unused variable 'ak2' [-Wunused-variable]
   21 |     ll ak2 = 1;
      |        ^~~
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:11:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i, n) for(int i = 0; i < n; i++)
......
   42 |     rep(i, dp.size()) {
      |         ~~~~~~~~~~~~                
railroad.cpp:42:5: note: in expansion of macro 'rep'
   42 |     rep(i, dp.size()) {
      |     ^~~
railroad.cpp:11:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i, n) for(int i = 0; i < n; i++)
......
   48 |     rep(j, dp[0].size()) {
      |         ~~~~~~~~~~~~~~~             
railroad.cpp:48:5: note: in expansion of macro 'rep'
   48 |     rep(j, dp[0].size()) {
      |     ^~~
railroad.cpp:11:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i, n) for(int i = 0; i < n; i++)
......
   51 |     rep(i, dp.size()) {
      |         ~~~~~~~~~~~~                
railroad.cpp:51:5: note: in expansion of macro 'rep'
   51 |     rep(i, dp.size()) {
      |     ^~~
railroad.cpp:11:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 | #define rep(i, n) for(int i = 0; i < n; i++)
......
   61 |     rep(i, dp[dp.size() - 1].size()) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
railroad.cpp:61:5: note: in expansion of macro 'rep'
   61 |     rep(i, dp[dp.size() - 1].size()) {
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...