Submission #105464

#TimeUsernameProblemLanguageResultExecution timeMemory
105464polyfishRoller Coaster Railroad (IOI16_railroad)C++14
Compilation error
0 ms0 KiB
//Pantyhose(black) + glasses = infinity #include <bits/stdc++.h> using namespace std; #define debug(x) cerr << #x << " = " << x << '\n'; #define BP() cerr << "OK!\n"; #define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';} #define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';} #define FILE_NAME "data" const int64_t INF = 1e18; int n; vector<pair<int, int> > a; int64_t f[1<<16][16]; int64_t dp(int mask, int last) { if (__builtin_popcount(mask)==n) return 0; if (f[mask][last]>-1) return f[mask][last]; int64_t res = INF; for (int i=0; i<n; ++i) { if (((mask>>i) & 1)==0) { int new_mask = mask | (1<<i); // if (mask==11 && last==1 && i==2) // debug(); res = min(res, dp(new_mask, i) + max(0, a[last].second - a[i].first)); } } return f[mask][last] = res; } bool check() { vector<int> L(n); for (int i=0; i<n; ++i) L[i] = upper_bound(a.begin(), a.end(), make_pair(a[i].second, 0)) - a.begin() - 1; set<int> avail; for (int i=0; i<n; ++i) avail.insert(i); int cur = n-1; avail.erase(n-1); for (int i=0; i+1<n; ++i) { auto it = avail.upper_bound(L[cur]); if (it==avail.begin()) return false; --it; cur = *it; avail.erase(*it); } return true; } int64_t plan_roller_coaster(vector<int> s, vector<int> t) { n = s.size(); a.resize(n); for (int i=0; i<n; ++i) a[i] = {s[i], t[i]}; sort(a.begin(), a.end(), greater<pair<int, int> >()); if (n<=16) { memset(f, -1, sizeof(f)); // debug(dp(1, 0)); int64_t res = INF; for (int i=0; i<n; ++i) res = min(res, dp(1<<i, i)); return res; } return check(); } int main() { #ifdef GLASSES_GIRL freopen(FILE_NAME".in", "r", stdin); freopen(FILE_NAME".out", "w", stdout); #endif ios::sync_with_stdio(0); cin.tie(0); cin >> n; vector<int> s(n), t(n); for (int i=0; i<n; ++i) cin >> s[i]; for (int i=0; i<n; ++i) cin >> t[i]; cout << plan_roller_coaster(s, t); }

Compilation message (stderr)

/tmp/ccdTvMup.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccOQaA4m.o:railroad.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status