제출 #1052785

#제출 시각아이디문제언어결과실행 시간메모리
1052785Itamar모임들 (IOI18_meetings)C++14
컴파일 에러
0 ms0 KiB
using namespace std; #include <vector> #define ll long long #define vll vector<ll> vll h; struct node{ int l,r,mid,ones,pref,suf; node* sl,*sr; node(int li, int ri){ l = li, r = ri, mid = (l+r)/2; if(l<r){ sl = new node(l,mid); sr = new node(mid+1,r); if(sl->ones == mid-l+1)pref = r-l+1 + sr->pref; else pref = sl->pref; if(sr->ones == r-mid)suf = r-mid+sl->suf; else suf = sr->suf; ones = max({sl->ones,sr->ones,sl->suf+sr->pref}); }else{ ones = h[l]%2; pref=ones, suf = pref; } } int query(int a, int b){ if(a > r || b < l)return 0; if(a <= l && b>=r)return ones; if(a > mid)return sr->query(a,b); if(b <= mid)return sl->query(a,b); return max({sl->query(a,b),sr->query(a,b),min(sl->suf,mid-a+1)+min(sr->pref,b-mid)}); } }; std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L, std::vector<int> R) { for(int hi :H)h.push_back(hi); int Q = L.size(); std::vector<ll> ans(Q); int N= H.size(); node* seg = new node(0,N-1); for (int j = 0; j < Q; ++j) { ans[j] = 2*(R[j]-L[j]+1) -seg->query(L[j],R[j]); } return ans; }

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

meetings.cpp: In constructor 'node::node(int, int)':
meetings.cpp:19:54: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   19 |       ones = max({sl->ones,sr->ones,sl->suf+sr->pref});
      |                                                      ^
In file included from /usr/include/c++/10/vector:60,
                 from meetings.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
meetings.cpp:19:54: note:   candidate expects 2 arguments, 1 provided
   19 |       ones = max({sl->ones,sr->ones,sl->suf+sr->pref});
      |                                                      ^
In file included from /usr/include/c++/10/vector:60,
                 from meetings.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
meetings.cpp:19:54: note:   candidate expects 3 arguments, 1 provided
   19 |       ones = max({sl->ones,sr->ones,sl->suf+sr->pref});
      |                                                      ^
meetings.cpp: In member function 'int node::query(int, int)':
meetings.cpp:30:88: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   30 |     return max({sl->query(a,b),sr->query(a,b),min(sl->suf,mid-a+1)+min(sr->pref,b-mid)});
      |                                                                                        ^
In file included from /usr/include/c++/10/vector:60,
                 from meetings.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
meetings.cpp:30:88: note:   candidate expects 2 arguments, 1 provided
   30 |     return max({sl->query(a,b),sr->query(a,b),min(sl->suf,mid-a+1)+min(sr->pref,b-mid)});
      |                                                                                        ^
In file included from /usr/include/c++/10/vector:60,
                 from meetings.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
meetings.cpp:30:88: note:   candidate expects 3 arguments, 1 provided
   30 |     return max({sl->query(a,b),sr->query(a,b),min(sl->suf,mid-a+1)+min(sr->pref,b-mid)});
      |                                                                                        ^