Submission #42413

# Submission time Handle Problem Language Result Execution time Memory
42413 2018-02-26T21:20:06 Z yusufake Ancient Books (IOI17_books) C++
Compilation error
0 ms 0 KB
#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: In function 'll minimum_walk(int*, int)':
books.cpp:26:13: warning: 'sizeof' on array function parameter 'p' will return size of 'int*' [-Wsizeof-array-argument]
  n = sizeof p / 4;
             ^
books.cpp:23:23: note: declared here
 ll minimum_walk(int p[], int s){
                       ^
/tmp/ccHFST4e.o: In function `main':
grader.cpp:(.text.startup+0x1b6): undefined reference to `minimum_walk(std::vector<int, std::allocator<int> >, int)'
collect2: error: ld returned 1 exit status