제출 #1083167

#제출 시각아이디문제언어결과실행 시간메모리
1083167Math4Life2020고대 책들 (IOI17_books)C++17
컴파일 에러
0 ms0 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

books.cpp: In function 'll minimum_walk(int*, int)':
books.cpp:7:16: warning: 'sizeof' on array function parameter 'p' will return size of 'int*' [-Wsizeof-array-argument]
    7 |  ll N = sizeof(p);
      |               ~^~
books.cpp:6:21: note: declared here
    6 | ll minimum_walk(int p[], int s) {
      |                 ~~~~^~~
/usr/bin/ld: /tmp/ccpgVWxi.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccmfhaHh.o:books.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccpgVWxi.o: in function `main':
grader.cpp:(.text.startup+0x266): undefined reference to `minimum_walk(std::vector<int, std::allocator<int> >, int)'
collect2: error: ld returned 1 exit status