#include<bits/stdc++.h>
using namespace std;
#define _ int v, int tl, int tr, int l, int r
#define tm (tl+tr >> 1)
#define sol v+v,tl,tm,l,r
#define sag v+v+1,tm+1,tr,l,r
#define mp make_pair
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef pair < ll , ll > pp;
const int mod = 1e9 + 7;
const int N = 1e6 + 6;
ll H[N],A[N],n,i,l,r,t,x;
ll minimum_walk(int[] p, int s){
memset(H , 0 , sizeof H);
x = t = 0;
n = sizeof p / 4;
for(i=0;i<n;i++){
x += abs(p[i] - i);
if(H[i]) continue;
l = r = i;
for(x=i; !H[x] ; x = p[x]){
H[x] = 1;
l = min(l , i);
r = max(r , i);
}
A[l] = r;
}
for(r=-1,i=0;i<n;i++){
if(i > r) t++;
r = max(r , A[i]);
}
return x + (t-1)*2;
}
Compilation message
books.cpp:23:23: error: expected ',' or '...' before 'p'
ll minimum_walk(int[] p, int s){
^
books.cpp: In function 'll minimum_walk(int*)':
books.cpp:26:13: error: 'p' was not declared in this scope
n = sizeof p / 4;
^