제출 #1022743

#제출 시각아이디문제언어결과실행 시간메모리
1022743hotboy2703모임들 (IOI18_meetings)C++17
컴파일 에러
0 ms0 KiB
#include "meetings.h" #include<bits/stdc++.h> using namespace std; using ll = long long; #define MP make_pair #define pll pair <ll,ll> #define fi first #define se second #define sz(a) (ll((a).size())) #define BIT(mask,i) (((mask) >> (i))&1LL) #define MASK(i) (1LL << (i)) ll n,q; const ll MAXN = 7.5e5+100; const ll MAXK = 20; const ll INF = 1e18; int sp[MAXK][MAXN]; vector <ll> res; pll all_queries[MAXN]; vector <pair <pll,ll> > questions[MAXN]; ll a[MAXN]; struct line{ int a; ll b; int r; ll eval(ll x,ll lazy){ return a * x + b + lazy; } }; ll max_id(ll l,ll r){ ll sz = __lg(r-l+1); ll L = sp[sz][l],R = sp[sz][r-MASK(sz)+1]; if (a[R] > a[L])return R; else return L; } ll intersect(line i,line j,ll lazy){ j.b+=lazy; if (j.a==i.a)return i.b>j.b?-INF:INF; return (i.b-j.b)/(j.a-i.a); } void dfs(ll l,ll r,deque <line> &s,ll &lazy){ if (l > r)return; ll mid = max_id(l,r); // cout<<"DFS "<<l<<' '<<r<<' '<<mid<<endl; deque <line> L,R; ll wL=0,wR=0; dfs(l,mid-1,L,wL); dfs(mid+1,r,R,wR); wR += (mid-l+1)*a[mid]; line T; T.a = a[mid]; T.b = a[mid] * (-l+1); T.r = mid; if (mid != l)T.b = L.back().eval(mid-1,wL) + a[mid] - a[mid] * mid; while (!R.empty()&&intersect(T,R.front(),wR) >= R.front().r){ T.r = R.front().r; R.pop_front(); } if (!R.empty()){ T.r = max(T.r,intersect(T,R.front(),wR)); } // cout<<"DFS "<<l<<' '<<r<<' '<<mid<<endl; // if (sz(L))cout<<"T "<<T.a<<' '<<T.b<<' '<<L.back().a<<' '<<L.back().b<<' '<<L.back().eval(mid-1)<<' '<<a[mid] - a[mid] * mid<<endl; if (mid-l+1>r-mid){ swap(s,L); swap(lazy,wL); s.push_back({T.a,T.b - lazy,T.r}); for (auto x:R){ x.b += wR-lazy; s.push_back(x); } } else{ swap(s,R); swap(lazy,wR); s.push_front({T.a,T.b - lazy,T.r}); for (ll i = sz(L)-1;i>=0;i--){ line x = L[i]; x.b += wL-lazy; s.push_front(x); } } // cout<<"DFS "<<l<<' '<<r<<' '<<mid<<endl; // for (auto x:s){ // cout<<x.a<<' '<<x.b+lazy<<' '<<x.r<<endl; // } while (!questions[l].empty() && questions[l].back().fi.fi <= r){ ll id = questions[l].back().fi.se; ll pre = questions[l].back().se; ll y = questions[l].back().fi.fi; res[id] = min(res[id],pre + (*lower_bound(s.begin(),s.end(),y,[](line x,ll val){return x.r < val;})).eval(y,lazy)); questions[l].pop_back(); } } void solve(){ for (ll i = 0;i < n;i ++)sp[0][i] = i; for (ll j = 1;j < MAXK;j ++){ for (ll i = 0;i + MASK(j) - 1 < n;i ++){ if (a[sp[j-1][i+MASK(j-1)]] > a[sp[j-1][i]])sp[j][i] = sp[j-1][i+MASK(j-1)]; else sp[j][i] = sp[j-1][i]; } } for (ll i = 0;i < n;i ++)questions[i].clear(); for (ll i = 0;i < q;i ++){ ll l = all_queries[i].fi,r = all_queries[i].se; ll mid = max_id(l,r); if (mid < r)questions[mid+1].push_back(MP(MP(r,i),a[mid] * (mid-l+1))); res[i] = min(res[i],a[mid]*(r-l+1)); } for (ll i = 0;i < n;i ++){ sort(questions[i].begin(),questions[i].end(),greater <>()); } deque <line> tmp; ll tmp2; dfs(0,n-1,tmp,tmp2); } std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L, std::vector<int> R){ n = sz(H); q = sz(L); res=vector <ll> (q,INF); for (ll i = 0;i < n;i ++)a[i] = H[i]; for (ll i = 0;i < q;i ++){ all_queries[i] = MP(L[i],R[i]); } solve(); reverse(a,a+n); for (ll i = 0;i < q;i ++){ all_queries[i] = MP(n-1-R[i],n-1-L[i]); } solve(); return res; }

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

meetings.cpp: In function 'void dfs(ll, ll, std::deque<line>&, ll&)':
meetings.cpp:60:48: error: no matching function for call to 'max(int&, ll)'
   60 |         T.r = max(T.r,intersect(T,R.front(),wR));
      |                                                ^
In file included from /usr/include/c++/10/vector:60,
                 from meetings.h:3,
                 from meetings.cpp:1:
/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:60:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   60 |         T.r = max(T.r,intersect(T,R.front(),wR));
      |                                                ^
In file included from /usr/include/c++/10/vector:60,
                 from meetings.h:3,
                 from meetings.cpp:1:
/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:60:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   60 |         T.r = max(T.r,intersect(T,R.front(),wR));
      |                                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from meetings.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
meetings.cpp:60:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   60 |         T.r = max(T.r,intersect(T,R.front(),wR));
      |                                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from meetings.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
meetings.cpp:60:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   60 |         T.r = max(T.r,intersect(T,R.front(),wR));
      |                                                ^