Submission #1042196

#TimeUsernameProblemLanguageResultExecution timeMemory
1042196raphaelpAncient Books (IOI17_books)C++17
Compilation error
0 ms0 KiB
#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 (stderr)

books.cpp: In function 'long long int minimum_walk(int*, int)':
books.cpp:5:15: error: request for member 'size' in 'p', which is of non-class type 'int*'
    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 | {
      | ^