Submission #24508

# Submission time Handle Problem Language Result Execution time Memory
24508 2017-06-09T14:16:29 Z Donghyun Kim(#1043) Roller Coaster Railroad (IOI16_railroad) C++
Compilation error
0 ms 0 KB
#include "railroad.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int n, S[200010], T[200010], chk[17][65536];
ll dp[17][65536];
const ll inf = 1e18;
set<pii> ss;
priority_queue<pii, vector<pii>, greater<pii>> pq;

ll f(int x, int st){
    if(!st) return 0;
    if(chk[x][st]) return dp[x][st];
    chk[x][st] = 1;
    dp[x][st] = inf;
    for(int i = 0; i < n; i++){
		if((1 << i) & st){
			dp[x][st] = min(dp[x][st], f(i, st - (1 << i)) + (ll)max(0, T[x] - S[i]));
		}
    }
    return dp[x][st];
}

ll plan_roller_coaster(vector<int> s, vector<int> t) {
    n = (int)s.size();
	for(int i = 0; i < n; i++){ S[i] = s[i]; T[i] = t[i]; }
    if(n <= 16){
		T[n] = 1;
		return f(n, (1 << n) - 1);
    }
    for(int i = 0; i < n; i++){
		ss.insert({s[i], i});
		pq.push({t[i], i});
    }
    for(int i = 0; i < n; i++){
		pii c = pq.top(); pq.pop();
        auto it = ss.upper_bound(c);
        if(it != ss.end()) ss.erase(it);
    }
    return ss.size() > 1;
}

Compilation message

railroad.cpp:11:45: error: '>>' should be '> >' within a nested template argument list
 priority_queue<pii, vector<pii>, greater<pii>> pq;
                                             ^
railroad.cpp: In function 'll plan_roller_coaster(std::vector<int>, std::vector<int>)':
railroad.cpp:34:13: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   ss.insert({s[i], i});
             ^
railroad.cpp:34:22: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   ss.insert({s[i], i});
                      ^
railroad.cpp:35:11: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   pq.push({t[i], i});
           ^
railroad.cpp:35:20: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11
   pq.push({t[i], i});
                    ^
railroad.cpp:39:9: warning: 'auto' changes meaning in C++11; please remove it [-Wc++0x-compat]
         auto it = ss.upper_bound(c);
         ^
railroad.cpp:39:14: error: 'it' does not name a type
         auto it = ss.upper_bound(c);
              ^
railroad.cpp:40:12: error: 'it' was not declared in this scope
         if(it != ss.end()) ss.erase(it);
            ^