Submission #105027

#TimeUsernameProblemLanguageResultExecution timeMemory
105027bert30702Simurgh (IOI17_simurgh)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "books.h" #define pii pair<int, int> #define F first #define S second using namespace std; const int MX = 1e6 + 100; int boss[MX]; int Find(int u) { return boss[u] == u ? u : boss[u] = Find(boss[u]); } void merge(int a, int b) { boss[Find(a)] = Find(b); } priority_queue<int> pq[MX]; long long minimun_walk(vector<int> p, int s) { long long sum = 0; for(int i = 0; i < p.size(); i ++) boss[i] = i; for(int i = 0; i < p.size(); i ++) sum += abs(i - p[i]), merge(i, p[i]); for(int i = 0; i < p.size(); i ++) pq[Find(i)].push(i); multiset<pii> ms; for(int i = 0; i < p.size(); i ++) { if(i == Find(i)) ms.insert({pq[i].top(), i}); } long long ans = 1ll << 60; for(int i = p.size() - 1; i >= 0; i --) { int a = (--ms.end()) -> F; int b = (ms.begin()) -> F; if((a > s and b > s) or (a < s and b < s)) { ans = min(ans, sum + max(abs(s - a), abs(s - b)) * 2); } else { ans = min(ans, sum + (a - b) * 2); } if((--ms.end()) -> F == i) { int ptr = (--ms.end()) -> S; ms.erase(--ms.end()); pq[ptr].pop(); if(pq[ptr].size()) ms.insert({pq[ptr].top(), ptr}); else return ans; } } }

Compilation message (stderr)

simurgh.cpp:2:10: fatal error: books.h: No such file or directory
 #include "books.h"
          ^~~~~~~~~
compilation terminated.