제출 #115205

#제출 시각아이디문제언어결과실행 시간메모리
115205minhtung0404Building Bridges (CEOI17_building)C++17
컴파일 에러
0 ms0 KiB
//https://oj.uz/problem/view/CEOI17_building #include<bits/stdc++.h> const int N = 1e6 + 5; const int inf = 1e9; using namespace std; struct line { long long x, y; long long get(long long val) { return val * x + y; } line (long long x, long long y) : x(x), y(y) {} line() {} } it[4 * N]; struct LiChaoTree { #define m ((l + r) >> 1) void init() { for(int i = 0; i < 4 * N; ++i) it[i].x = 0, it[i].y = inf; } void add_line(int node, int l, int r, line u) { bool lef = u.get(l) < it[node].get(l); bool mid = u.get(m) < it[node].get(m); if(mid) swap(it[node], u); if(l == r) return; if(lef != mid) add_line(node << 1, l, m, u); else add_line(node << 1 | 1, m + 1, r, u); } long long get(int node, int l, int r, int u) { if(l == r) return it[node].get(u); if(u <= m) return min(it[node].get(u), get(node << 1, l, m, u)); return min(it[node].get(u), get(node << 1 | 1, m + 1, r, u)); } #undef m } data; int n; long long dp[N], h[N], w[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1; i <= n; i++) cin >> h[i]; for (int i = 1; i <= n; i++) cin >> w[i]; dp[1] = -w[1]; data.add_line(1, 0, N-1, line(-2*h[1], dp[1] + 1LL * h[1] * h[1])); for (int i = 2; i <= n; i++){ dp[i] = 1LL * h[i] * h[i] - w[i] + data.get(1, 0, N-1, h[i]); data.add_line(1, 0, N-1, line(-2*h[i], dp[i] + 1LL * h[i] * h[i])); } for (int i = 1; i <= n; i++) dp[n] += w[i]; cout << dp[n]; }

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

building.cpp: In function 'int main()':
building.cpp:44:20: error: reference to 'data' is ambiguous
     dp[1] = -w[1]; data.add_line(1, 0, N-1, line(-2*h[1], dp[1] + 1LL * h[1] * h[1]));
                    ^~~~
building.cpp:34:3: note: candidates are: LiChaoTree data
 } data;
   ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from building.cpp:3:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
building.cpp:46:44: error: reference to 'data' is ambiguous
         dp[i] = 1LL * h[i] * h[i] - w[i] + data.get(1, 0, N-1, h[i]);
                                            ^~~~
building.cpp:34:3: note: candidates are: LiChaoTree data
 } data;
   ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from building.cpp:3:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
building.cpp:47:9: error: reference to 'data' is ambiguous
         data.add_line(1, 0, N-1, line(-2*h[i], dp[i] + 1LL * h[i] * h[i]));
         ^~~~
building.cpp:34:3: note: candidates are: LiChaoTree data
 } data;
   ^~~~
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from building.cpp:3:
/usr/include/c++/7/bits/range_access.h:318:5: note:                 template<class _Tp> constexpr const _Tp* std::data(std::initializer_list<_Tp>)
     data(initializer_list<_Tp> __il) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:309:5: note:                 template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])
     data(_Tp (&__array)[_Nm]) noexcept
     ^~~~
/usr/include/c++/7/bits/range_access.h:299:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)
     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~
/usr/include/c++/7/bits/range_access.h:289:5: note:                 template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)
     data(_Container& __cont) noexcept(noexcept(__cont.data()))
     ^~~~