Submission #109495

# Submission time Handle Problem Language Result Execution time Memory
109495 2019-05-06T17:55:41 Z updown1 Ancient Books (IOI17_books) C++17
Compilation error
0 ms 0 KB
#include "books.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, a, b) for(int i=a; i<b; i++)
#define ffi For(i, 0, N)
#define ffj For(j, 0, M)
#define ffa ffi ffj
//#define s <<" "<<
#define w cout
#define e "\n"
#define pb push_back
#define mp make_pair
#define a first
#define b second
#define int ll
const int MAXN = 1000000;
//Global Variables
int N, out = 0, loc[MAXN];
bool vis[MAXN];

void go(int at) {
	if (vis[at]) return;
	vis[at] = true;
	out += abs(loc[at]-at);
	go(loc[at]);
}

int minimum_walk(vector<int> p, int s) {
	N = p.size();
	ffi loc[i] = p[i];
	int far_rig = 0, far_lef = 0;
	For (i, s, N) if (!vis[i]) {far_rig = i; go(i);}
	for (int i=s-1; i>=0; i--) if (!vis[i]) {far_lef = i; go(i);}
	return out+2*((s-far_lef)+(far_rig-s));
}

Compilation message

/tmp/ccg0Tc8O.o: In function `main':
grader.cpp:(.text.startup+0x23a): undefined reference to `minimum_walk(std::vector<int, std::allocator<int> >, int)'
collect2: error: ld returned 1 exit status