Submission #662902

# Submission time Handle Problem Language Result Execution time Memory
662902 2022-11-26T13:19:47 Z Trisanu_Das Roller Coaster Railroad (IOI16_railroad) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
 
vector<int> nxt;
int parent(int u) { return nxt[u] != -1 ? nxt[u] = parent(nxt[u]) : u; }
bool unite(int u, int v) {
	u = parent(u); v = parent(v);
	if (u == v) return false;
	nxt[v] = u; return true;
}
 
ll plan_roller_coaster(vector<int> s, vector<int> t) {
	s.push_back(inf); t.push_back(1); int n = s.size();
	vector<int> p = s; p.insert(p.end(), t.begin(), t.end());
	sort(p.begin()); p.erase(unique(p.begin(), p.end()), p.end());	
	int m = p.size(); nxt.resize(m, -1);
	vector<int> b(m--);
	for(int i = 0; i < n; i++) {
		int l = lower_bound(p.begin(), p.end(), s[i]) - p.begin(), r = lower_bound(p.begin(), p.end(), t[i]) - p.begin();
		unite(l, r); ++b[l]; --b[r];
	}
	for(int i = 0; i < m; i++) b[i + 1] += b[i];
	vector<pair<int, int>> e; ll ans = 0;
	for(int i = 0; i < m; i++) {
		ll d = p[i + 1] - p[i];
		if (b[i]) {
			unite(i, i + 1);
			if (b[i] > 0) ans += b[i] * d;
		} else e.push_back(d, i);
	}
	sort(e.begin(), e.end());
	for (auto u : e) if (unite(u.second, u.second + 1)) ans += u.first;
	return ans;
}

Compilation message

railroad.cpp:13:1: error: 'll' does not name a type
   13 | ll plan_roller_coaster(vector<int> s, vector<int> t) {
      | ^~