Submission #1069672

#TimeUsernameProblemLanguageResultExecution timeMemory
1069672mc061Roller Coaster Railroad (IOI16_railroad)C++14
34 / 100
37 ms15184 KiB
#pragma once #include <bits/stdc++.h> using namespace std; const int N = 16; int64_t ham_path[1<<N][N]; int64_t dist[N][N]; long long plan_roller_coaster(vector<int> s, vector<int> t) { const int n = s.size(); for (int i = 0; i < (1<<n); ++i) { fill(ham_path[i], ham_path[i]+n, 1e18); } ham_path[0][0] = 0; for (int i = 0; i < n; ++i) { ham_path[1<<i][i] = 0; } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { if (i==j) { dist[i][j]=1e18; continue; } dist[i][j] = max(0, t[i]-s[j]); } } for (int m = 1; m < (1<<n); ++m) { vector<int> bits; for (int bit = 0; bit < n; ++bit) { if ((m & (1 << bit)) == 0) continue; bits.push_back(bit); } if (bits.size() == 1) { continue; } for (int i = 0; i < bits.size(); ++i) { int prev_m = m ^ (1 << bits[i]); assert(prev_m < m); for (int j = 0; j < bits.size(); ++j) { if (i == j) continue; ham_path[m][bits[i]] = min(ham_path[m][bits[i]], ham_path[prev_m][bits[j]] + dist[bits[j]][bits[i]]); } } } return *min_element(ham_path[(1<<n)-1], ham_path[(1<<n)-1]+n); }

Compilation message (stderr)

railroad.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
railroad.cpp: In function 'long long int plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:39:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (int i = 0; i < bits.size(); ++i) {
      |                         ~~^~~~~~~~~~~~~
railroad.cpp:42:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             for (int j = 0; j < bits.size(); ++j) {
      |                             ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...