Submission #1042195

# Submission time Handle Problem Language Result Execution time Memory
1042195 2024-08-02T15:54:45 Z raphaelp Ancient Books (IOI17_books) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
long long minimum_walk(int[] p, int s)
{
long long N=p.size();
int64 ans=0;
for (int i=0; i<N; i++)
{
ans+=abs(i-p[i]);
}
vector<int>occ(N);
for(int i=0; i<N; i++)
{
if(occ[i])continue;
int x=i;
ans+=2;
while(!occ[x])
{
occ[x]=1;
x=p[x];
}
return ans-2;
}

Compilation message

books.cpp:3:30: error: expected ',' or '...' before 'p'
    3 | long long minimum_walk(int[] p, int s)
      |                              ^
books.cpp: In function 'long long int minimum_walk(int*)':
books.cpp:5:13: error: 'p' was not declared in this scope
    5 | long long N=p.size();
      |             ^
books.cpp:6:1: error: 'int64' was not declared in this scope; did you mean 'int64_t'?
    6 | int64 ans=0;
      | ^~~~~
      | int64_t
books.cpp:9:1: error: 'ans' was not declared in this scope; did you mean 'abs'?
    9 | ans+=abs(i-p[i]);
      | ^~~
      | abs
books.cpp:16:1: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 | ans+=2;
      | ^~~
      | abs
books.cpp:23:1: error: expected '}' at end of input
   23 | }
      | ^
books.cpp:4:1: note: to match this '{'
    4 | {
      | ^