#include "books.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+5;
int cnt[maxn],f[maxn];
long long minimum_walk(std::vector<int> p, int s) {
long long ans=0;
int n=(int)p.size();
for(int i=0;i<n;i++){
if(!f[i] && i!=p[i]){
int u=i,mn=i,mx=i;
while(!f[u]){
f[u]=1;
mn=min(mn,u);
mx=max(mx,u);
u=p[u];
}
cnt[mn]++;
cnt[mx]--;
}
ans+=abs(i-p[i]);
}
for(int i=1;i<=n;i++) cnt[i]+=cnt[i-1];
int d=0;
for(int i=n-1;i>=s;i--){
if(cnt[i]) d=1;
else ans+=2*d;
}
d=0;
for(int i=0;i<s;i++){
if(cnt[i]) d=1;
else ans+=2*d;
}
return ans;
}
Compilation message
sorting.cpp:1:10: fatal error: books.h: No such file or directory
1 | #include "books.h"
| ^~~~~~~~~
compilation terminated.