Submission #540254

#TimeUsernameProblemLanguageResultExecution timeMemory
540254new_accAliens (IOI16_aliens)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define fi first #define se second #define pitem item* using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; const ll M=1e6+10; const ll N=1e5+10; const ll SS=1<<20; const ll INFi=1e9; const ll INFl=1e12; struct f{ ll a,b; ll ind; ll operator()(ll x){ return a*x+b; } }; struct item{ f fun; item *l,*r; }; pair<ll,ll> dp[N]; f nullp; bool cmp(f a,f b,ll p,ll k){ if((a(p)<b(p) and a(k)<b(k)) or (a(p)<=b(p) and a(k)<b(k)) or (a(p)<b(p) and a(k)<=b(k))) return 1; if(a(p)==b(p) and a(k)==b(k) and dp[a.ind].se<dp[b.ind].se) return 1; return 0; } pitem upd(pitem v,f x,ll p=0,ll k=SS-1){ if(p>k) return nullptr; if(!v){ v=new item; v->l=nullptr,v->r=nullptr,v->fun=x; return v; } ll sr=(p+k)>>1; if(cmp(x,v->fun,p,sr)){ v->r=upd(v->r,v->fun,sr+1,k); v->fun=x; }else if(cmp(x,v->fun,sr+1,k)){ v->l=upd(v->l,v->fun,p,sr); v->fun=x; }else if(cmp(v->fun,x,p,sr)) v->r=upd(v->r,x,sr+1,k); else v->l=upd(v->l,x,p,sr); return v; } f Query(pitem v,ll x,ll p=0,ll k=SS-1){ if(!v) return nullp; f pom; if(x<=((p+k)>>1)) pom=Query(v->l,x,p,(p+k)>>1); else pom=Query(v->r,x,((p+k)>>1)+1,k); if(cmp(v->fun,pom,x,x)) return v->fun; return pom; } void clear(pitem v){ if(!v) return; clear(v->l),clear(v->r); delete(v); } ll t[N],l,val[N],mini[M],mini2[M],kw[N]; ll res=INFl; ll wsp(ll i){ if(t[i]-val[i]+1>kw[i]) return INFi; if(val[i]>t[i]) return 0; return (ll)(t[i]-val[i]+1)*(ll)(t[i]-val[i]+1); } f func(ll i){ ll w=wsp(i); if(w==INFi) return nullp; f pom; pom.a=-2LL*val[i],pom.b=dp[i].fi+(ll)val[i]*(ll)val[i]+1LL-2LL*(ll)val[i]-(ll)w; pom.ind=i; return pom; } bool check(ll c,ll k){ pitem v=nullptr; ll mm=INFi; for(ll i=1;i<=l;i++){ mm=min(mm,mini[t[i]]); ll pom1=INFl; f curr=Query(v,t[i]); if(curr.b!=INFl) pom1=curr((ll)t[i])+(ll)t[i]*(ll)t[i]+2LL*(ll)t[i]+c; dp[i]={(ll)(t[i]-mm+1)*(ll)(t[i]-mm+1)+c,1}; kw[i]=t[i]-mm+1; if(dp[i].fi>pom1){ dp[i]={pom1,dp[curr.ind].se+1}; kw[i]=t[i]-val[curr.ind]+1; } if(i!=l){ f pom2=func(i); if(pom2.b!=INFl) v=upd(v,pom2); } } clear(v); if(dp[l].se<=k){ res=dp[l].fi-(ll)k*c; return 1; } return 0; } ll take_photos(ll n,ll m,ll k,vi r,vi c){ nullp.a=INFi,nullp.b=INFl; for(ll i=1;i<=m;i++) mini[i]=INFi; for(ll i=1;i<=n;i++){ r[i-1]++,c[i-1]++; if(r[i-1]>c[i-1]) swap(r[i-1],c[i-1]); mini[c[i-1]]=min(mini[c[i-1]],r[i-1]); } ll akt=INFi; for(ll i=m;i>=1;i--){ mini2[i]=akt; akt=min(akt,mini[i]); } for(ll i=1;i<=m;i++) if(mini[i]!=INFi) t[++l]=i,val[l]=mini2[i]; ll pocz=0,kon=1000LL*1000LL*1000LL*1000LL+10LL; while(pocz<=kon){ ll sr=(pocz+kon)>>1; if(check(sr,k)) kon=sr-1; else pocz=sr+1; } return res; } /*ll main(){ ll n,m,k; cin>>n>>m>>k; vi r,c; for(ll i=1,a,b;i<=n;i++){ cin>>a>>b; r.push_back(a),c.push_back(b); } cout<<take_photos(n,m,k,r,c)<<"\n"; }*/

Compilation message (stderr)

aliens.cpp: In function 'll take_photos(ll, ll, ll, vi, vi)':
aliens.cpp:111:45: error: no matching function for call to 'min(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
  111 |         mini[c[i-1]]=min(mini[c[i-1]],r[i-1]);
      |                                             ^
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/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from aliens.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:
aliens.cpp:111:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
  111 |         mini[c[i-1]]=min(mini[c[i-1]],r[i-1]);
      |                                             ^
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/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from aliens.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:
aliens.cpp:111:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
  111 |         mini[c[i-1]]=min(mini[c[i-1]],r[i-1]);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
aliens.cpp:111:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  111 |         mini[c[i-1]]=min(mini[c[i-1]],r[i-1]);
      |                                             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from aliens.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
aliens.cpp:111:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  111 |         mini[c[i-1]]=min(mini[c[i-1]],r[i-1]);
      |                                             ^