Submission #863292

#TimeUsernameProblemLanguageResultExecution timeMemory
863292ibm2006Meteors (POI11_met)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("avx") using namespace std; typedef long long int ll; typedef __int128 lll; ll n,e,i,j,k,x,z,w,l,r,m,q,a[330000],s,lazy[1100000]; int le[330000],ri[330000]; ll te1,te2,te3; lll seg[1100000],y; vector<int> v[330000],u[330000]; pair<int,int> p[330000]; pair<pair<int,int>,ll> upd[330000]; void h(ll x,ll y,ll z) { if(lazy[z]==0) return; if(z>=524288) { seg[z]+=lazy[z]; lazy[z]=0; return; } seg[z]+=(y-x+1)*lazy[z]; lazy[z*2]+=lazy[z]; lazy[z*2+1]+=lazy[z]; lazy[z]=0; return; } void Clear() { ll i; for(i=0;i<1100000;i++) { seg[i]=0; lazy[i]=0; } } void f(ll x,ll y,ll z,ll w) { h(x,y,z); if(l>y||x>r) return; if(l<=x&&y<=r) { lazy[z]+=w; h(x,y,z); return; } f(x,(x+y)/2,z*2,w); f((x+y)/2+1,y,z*2+1,w); seg[z]=seg[z*2]+seg[z*2+1]; } lll g(ll x,ll y,ll z) { h(x,y,z); if(l>y||x>r) return 0; if(l<=x&&y<=r) { return seg[z]; } return g(x,(x+y)/2,z*2)+g((x+y)/2+1,y,z*2+1); } int main() { scanf("%lld %lld",&te1,&te2); n=te1; m=te2; for(i=1;i<=m;i++) { scanf("%lld",&te1); x=te1; //x=1; v[x].push_back(i); } for(i=1;i<=n;i++) { scanf("%lld",&te1); a[i]=te1; //a[i]=1e9; } scanf("%lld",&te1); q=te1; for(i=1;i<=q;i++) { scanf("%lld %lld %lld",&te1,&te2,&te3); x=te1; w=te2; z=te3; //x=1; w=m; z=1; upd[i]={{x,w},z}; } for(i=1;i<=n;i++) { le[i]=1; ri[i]=q+1; p[i]={(le[i]+ri[i])/2,i}; } for(e=0;e<20;e++) { //printf("!"); //for(i=1;i<=n;i++) // printf("(%lld,%lld)\n",le[i],ri[i]); Clear(); s=1; for(i=1;i<=q+1;i++) { u[i].clear(); } for(i=1;i<=n;i++) u[p[i].first].push_back(p[i].second); for(i=1;i<=q+1;i++) { //printf("%lld\n",i); if(i<=q) {x=upd[i].first.first; y=upd[i].first.second; z=upd[i].second; if(x<=y) { l=x; r=y; f(1,524288,1,z); } else { l=x; r=m; f(1,524288,1,z); l=1; r=y; f(1,524288,1,z); } } //printf("?"); for(j=0;j<u[i].size();j++) { x=u[i][j]; y=0; for(k=0;k<v[x].size();k++) { l=v[x][k]; r=v[x][k]; y+=g(1,524288,1);} if(a[x]<=y) { ri[x]=i; } else le[x]=i+1; le[x]=min(le[x],q+1); // printf("[%lld,%lld]\n",(le[x]+ri[x])/2,x); p[s]={(le[x]+ri[x])/2,x}; s++; } } //swap(p,pp); } for(i=1;i<=n;i++) { a[p[i].second]=p[i].first; } for(i=1;i<=n;i++) { te1=a[i]; if(a[i]>=q+1) { printf("NIE\n"); } else printf("%lld\n",te1); } }

Compilation message (stderr)

met.cpp: In function 'int main()':
met.cpp:137:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  137 |             for(j=0;j<u[i].size();j++)
      |                     ~^~~~~~~~~~~~
met.cpp:141:26: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  141 |                 for(k=0;k<v[x].size();k++)
      |                         ~^~~~~~~~~~~~
met.cpp:150:17: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
  150 |                 else
      |                 ^~~~
met.cpp:152:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
  152 |                     le[x]=min(le[x],q+1);
      |                     ^~
met.cpp:152:40: error: no matching function for call to 'min(int&, ll)'
  152 |                     le[x]=min(le[x],q+1);
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.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:
met.cpp:152:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  152 |                     le[x]=min(le[x],q+1);
      |                                        ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from met.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:
met.cpp:152:40: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  152 |                     le[x]=min(le[x],q+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 met.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:
met.cpp:152:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  152 |                     le[x]=min(le[x],q+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 met.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:
met.cpp:152:40: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  152 |                     le[x]=min(le[x],q+1);
      |                                        ^
met.cpp:67:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |     scanf("%lld %lld",&te1,&te2);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
met.cpp:72:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         scanf("%lld",&te1);
      |         ~~~~~^~~~~~~~~~~~~
met.cpp:79:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   79 |         scanf("%lld",&te1);
      |         ~~~~~^~~~~~~~~~~~~
met.cpp:83:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   83 |     scanf("%lld",&te1);
      |     ~~~~~^~~~~~~~~~~~~
met.cpp:87:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |         scanf("%lld %lld %lld",&te1,&te2,&te3);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~