제출 #763269

#제출 시각아이디문제언어결과실행 시간메모리
763269cheat_when_I_was_youngXylophone (JOI18_xylophone)C++17
컴파일 에러
0 ms0 KiB
#include "xylophone.h" #include "bits/stdc++.h" int q[5005][5005], a[5005]; bool check_permutation(int n) { for (int i = 1; i < n; ++i) if (a[i+1] - a[i] != q[i+1][i]) return false; return true; } void build_permutation1(int n) { a[1] = 10000; a[2] = 10001; for (int i = 3; i <= n; ++i) { if (q[i-2][i-1] + q[i-1][i] == q[i-2][i]) { if (a[i-2] > a[i-1]) a[i] = a[i-1] - q[i-1][i]; else a[i] = a[i-1] + q[i-1][i]; } else { if (a[i-2] > a[i-1]) a[i] = a[i-1] + q[i-1][i]; else a[i] = a[i-1] - q[i-1][i]; } } int mi = *min_element(a+1, a+n+1) - 1; for (int i = 1; i <= n; ++i) a[i] -= mi; } void build_permutation2(int n) { a[1] = 10001; a[2] = 10000; for (int i = 3; i <= n; ++i) { if (q[i-2][i-1] + q[i-1][i] == q[i-2][i]) { if (a[i-2] > a[i-1]) a[i] = a[i-1] - q[i-1][i]; else a[i] = a[i-1] + q[i-1][i]; } else { if (a[i-2] > a[i-1]) a[i] = a[i-1] + q[i-1][i]; else a[i] = a[i-1] - q[i-1][i]; } } int mi = *min_element(a+1, a+n+1) - 1; for (int i = 1; i <= n; ++i) a[i] -= mi; } void solve(int n) { for (int i = 1; i <= n-1; ++i) q[i][i+1] = q[i+1][i] = query(i, i+1); for (int i = 1; i <= n-2; ++i) q[i][i+2] = q[i+2][i] = query(i, i+2); int pos = 1; for (int i = 1<<12; i > 0; i >>= 1) { if (pos + i > n) continue; if (query(pos + i, n) == n - 1) pos += i; } build_permutation1(n); if (check_permutation(n)) { for (int i = 1; i <= n; ++i) answer(i, a[i]); return; } build_permutation2(n); for (int i = 1; i <= n; ++i) answer(i, a[i]); }

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

xylophone.cpp: In function 'void build_permutation1(int)':
xylophone.cpp:20:12: error: 'min_element' was not declared in this scope; did you mean 'std::min_element'?
   20 |  int mi = *min_element(a+1, a+n+1) - 1;
      |            ^~~~~~~~~~~
      |            std::min_element
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:520:1: note: 'std::min_element' declared here
  520 | min_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~~~
xylophone.cpp: In function 'void build_permutation2(int)':
xylophone.cpp:35:12: error: 'min_element' was not declared in this scope; did you mean 'std::min_element'?
   35 |  int mi = *min_element(a+1, a+n+1) - 1;
      |            ^~~~~~~~~~~
      |            std::min_element
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from xylophone.cpp:2:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:520:1: note: 'std::min_element' declared here
  520 | min_element(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last);
      | ^~~~~~~~~~~