Submission #1042190

#TimeUsernameProblemLanguageResultExecution timeMemory
1042190raphaelpAncient Books (IOI17_books)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; int64_t minimum_walk(int[] p, int S) { int N=p.size(); int64_t 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 (stderr)

books.cpp:3:28: error: expected ',' or '...' before 'p'
    3 | int64_t minimum_walk(int[] p, int S)
      |                            ^
books.cpp: In function 'int64_t minimum_walk(int*)':
books.cpp:5:7: error: 'p' was not declared in this scope
    5 | int N=p.size();
      |       ^
books.cpp:23:1: error: expected '}' at end of input
   23 | }
      | ^
books.cpp:4:1: note: to match this '{'
    4 | {
      | ^
books.cpp:11:17: warning: control reaches end of non-void function [-Wreturn-type]
   11 | vector<int>occ(N);
      |                 ^