답안 #1083165

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083165 2024-09-02T17:07:46 Z Math4Life2020 고대 책들 (IOI17_books) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long; using pii = pair<ll,ll>;

ll minimum_walk(int[] p, int s) {
	ll N = sizeof(p);
	assert(s==0);
	ll ans = 0;
	bool found[N];
	for (ll i=0;i<N;i++) {
		found[i]=0;
	}
	ll D = 0;
	for (ll i=0;i<N;i++) {
		if (!found[i]) {
			ll j = i;
			ll dmin = 1e8;
			do {
				found[j]=1;
				dmin = min(dmin,j);
				ans += abs(p[j]-j);
				j = p[j];
			} while (j != i);
			D = max(D,dmin);
		}
	}
	ans -= 2*D;
	return ans;
}

int main() {
	return 0;
}

Compilation message

books.cpp:6:23: error: expected ',' or '...' before 'p'
    6 | ll minimum_walk(int[] p, int s) {
      |                       ^
books.cpp: In function 'll minimum_walk(int*)':
books.cpp:7:16: error: 'p' was not declared in this scope
    7 |  ll N = sizeof(p);
      |                ^
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from books.cpp:1:
books.cpp:8:9: error: 's' was not declared in this scope
    8 |  assert(s==0);
      |         ^