#include "books.h"
#include "bits/stdc++.h"
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(), x.end()
struct pii{int a, b;};
typedef vector<int> vi;
typedef set<int> si;
typedef vector<bool> vb;
typedef vector<vector<pii>> aList;
typedef long long ll;
long long minimum_walk(std::vector<int> p, int s) {
int n = p.size();
vector<pii> cy;
vb vis(n);
ll tot = 0;
forR(i, n) {
if(!vis[i]) {
vector<int> els = {i};
for(int pre=i, j = p[i]; j != i; pre=j, j = p[j]) {
assert(!vis[j]);
els.push_back(j);
}
for(int j : els) {
assert(!vis[j]);
vis[j] = true;
}
// for(int j : els) cout << j << ' ';
// cout << '\n';
if(els.size() > 1) {
cy.push_back({els[0], els[0]});
for(int j : els) {
cy.back().a = min(cy.back().a, j);
cy.back().b = max(cy.back().b, j);
}
REP(ci, 1, els.size()) tot += abs(els[ci] - els[ci-1]);
tot += abs(els.front() - els.back());
}
}
}
// cout << cy.size() << '\n';
sort(all(cy), [](pii a, pii b){return a.a < b.a;});
int rch = 0;
for(auto [a, b] : cy) {
if(a > rch) tot += 2 * (a - rch);
rch = max(rch, b);
}
return tot;
}
Compilation message
prize.cpp:1:10: fatal error: books.h: No such file or directory
1 | #include "books.h"
| ^~~~~~~~~
compilation terminated.