답안 #1042190

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1042190 2024-08-02T15:52:22 Z raphaelp 고대 책들 (IOI17_books) C++17
컴파일 오류
0 ms 0 KB
#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

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);
      |                 ^