제출 #424781

#제출 시각아이디문제언어결과실행 시간메모리
424781salehAncient Books (IOI17_books)C++17
컴파일 에러
0 ms0 KiB
#include "books.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 1000 * 1000 + 23; int mark[MAXN], cnt = 0, ans, jav; long long minimum_walk(std::vector<int> p, int s) { if (s != 0) return 0; for (int i = 0; i < n; i++) if (p[i] != i && mark[i] == 0) { int tmp = i, pre = i; mark[i] = ++cnt; while ((tmp = p[tmp]) != i) { mark[tmp] = cnt; jav += abs(pre - tmp); pre = tmp; } ans = max(ans, i); } return jav + ans * 2; } //int main() {}

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

books.cpp: In function 'long long int minimum_walk(std::vector<int>, int)':
books.cpp:13:22: error: 'n' was not declared in this scope
   13 |  for (int i = 0; i < n; i++) if (p[i] != i && mark[i] == 0) {
      |                      ^