제출 #1047151

#제출 시각아이디문제언어결과실행 시간메모리
1047151alex_2008Text editor (CEOI24_editor)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> using namespace std; const int N = 1e6 + 10; int l[N]; int st[N][21]; int lg2[N]; int mn[N]; void precalc() { lg2[1] = 0; for (int i = 2; i < N; i++) { lg2[i] = lg2[i / 2] + 1; } } int min_in_range(int l, int r) { int w = lg2[r - l + 1]; return min(st[l][w], st[r - (1 << w) + 1][w]); } int main() { precalc(); int n; cin >> n; int sl, sc, el, ec; cin >> sl >> sc >> el >> ec; for (int i = 1; i <= n; i++) { cin >> l[i]; l[i]++; } for (int i = n; i >= 1; i--) { st[i][0] = l[i]; for (int j = 1; j < 20; j++) { int pos = i + (1 << (j - 1)); st[i][j] = min(st[i][j - 1], st[pos][j - 1]); } } int ans = 1000000000 + n + 10; for (int i = 1; i <= n; i++) { int cur = 0; cur += abs(sl - i); cur += abs(i - el); int c = min({ sc, min_in_range(min(i, sl), max(i, sl)), min_in_range(min(i, el), max(i, el)) }); cur += abs(c - ec); ans = min(ans, cur); } for (int i = 1; i <= n; i++) { mn[i] = abs(sl - i) + min(min_in_range(min(i, sl), max(i, sl)), sc) - 1; if (i > 1) { mn[i] = min(mn[i], abs(sl - (i - 1)) + l[i - 1] + 1 - min(sc, min_in_range(min(i - 1, sl), max(i - 1, sl)))); } } for (int i = 2; i <= n; i++) { mn[i] = min(mn[i], mn[i - 1] + 1); } for (int i = n - 1; i >= 1; i--) { mn[i] = min(mn[i], mn[i + 1] + 1); } ans = min(ans, mn[el] + ec - 1); for (int i = 2; i <= n; i++) { //(i - 1, l[i]) int cur = mn[i] + 1; cur += abs(el - (i - 1)); int c = min_in_range(min(i - 1, el), max(i - 1, el)); cur += abs(c - ec); ans = min(ans, cur); } cout << ans << "\n"; }

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

Main.cpp: In function 'int main()':
Main.cpp:41:97: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
   41 |   int c = min({ sc, min_in_range(min(i, sl), max(i, sl)), min_in_range(min(i, el), max(i, el)) });
      |                                                                                                 ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
Main.cpp:41:97: note:   candidate expects 2 arguments, 1 provided
   41 |   int c = min({ sc, min_in_range(min(i, sl), max(i, sl)), min_in_range(min(i, el), max(i, el)) });
      |                                                                                                 ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from Main.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
Main.cpp:41:97: note:   candidate expects 3 arguments, 1 provided
   41 |   int c = min({ sc, min_in_range(min(i, sl), max(i, sl)), min_in_range(min(i, el), max(i, el)) });
      |                                                                                                 ^