Submission #390652

# Submission time Handle Problem Language Result Execution time Memory
390652 2021-04-16T13:07:39 Z alireza_kaviani Simurgh (IOI17_simurgh) C++11
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "books.h"
using namespace std;

typedef long long ll;

const int MAXN = 1e6 + 10;

int n;
ll ans , ps[MAXN];

ll minimum_walk(vector<int> p, int s) {
	n = p.size();
	for(int i = 0 ; i < n ; i++){
		ps[min(p[i] , i)]++;
		ps[max(p[i] , i)]--;
	}
	partial_sum(ps , ps + MAXN , ps);
	int l = 0 , r = n;
	while(l < s && ps[l] == 0)	l++;
	while(s <= r && ps[r] == 0)	r--;
	int x = p[s] , mn = s , mx = s , res = s;
	while(x != s){
		mn = min(mn , x);
		mx = max(mx , x);
		x = p[x];
	}
	for(int i = 0 ; i < mn ; i++){
		if(ps[i] == 0)	res = min(res , mn - i - 1);
	}
	for(int i = mx ; i < n ; i++){
		if(ps[i] == 0)	res = min(res , i - mx);
	}
	for(int i = l ; i <= r ; i++){
		ans += max(2ll , ps[i]);
	}
	return ans + res * 2;
}

Compilation message

simurgh.cpp:2:10: fatal error: books.h: No such file or directory
    2 | #include "books.h"
      |          ^~~~~~~~~
compilation terminated.