Submission #311916

#TimeUsernameProblemLanguageResultExecution timeMemory
311916YJUBubble Sort 2 (JOI18_bubblesort2)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #pragma GCC optimize("unroll-loops,no-stack-protector") using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll,ll> pll; const ll MOD=1e9+7; const ll MOD2=998244353; const ll N=4e5+5; const ll K=350; const ld pi=3.14159265359; const ll INF=(1LL<<40); #define SQ(i) ((i)*(i)) #define REP(i,n) for(ll i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define pb push_back #define mp make_pair #define X first #define Y second #define setp setprecision #define lwb lower_bound #define SZ(_a) (ll)_a.size() ll seg[4*N],cnt[4*N],ss[4*N]; vector<ll> lis; map<ll,ll> to; void insert(ll id,ll l,ll r,ll count,ll t,ll val){ if(l==r-1){ if(val<0)ss[id].erase(-val);else ss[id].insert(val); if(SZ(ss[id])==0){ seg[id]=cnt[id]=0; }else{ cnt[id]=SZ(ss[id]); seg[id]=*prev(ss[id])-(count+(SZ(ss[id])-1)); } return ; } ll mid=(l+r)/2; if(t<mid){ insert(id*2,l,mid,count,t,val); }else{ insert(id*2+1,mid,r,count+cnt[id*2],t,val); } seg[id]=max(seg[id*2],seg[id*2+1]); cnt[id]=cnt[id*2]+cnt[id*2+1]; } vector<ll> countScans(vector<ll> A,vector<ll> X,vector<ll> V){ vector<ll> ans; n=SZ(A);q=SZ(X); for(ll i:A)lis.pb(i); for(ll i:V)lis.pb(i); sort(lis.begin(),lis.end()); lis.resize(unique(lis.begin(),lis.end())-lis.begin()); REP(i,SZ(lis))to[lis[i]]=i; REP(i,n)insert(1,0,SZ(lis),0,to[A[i]],i); REP(i,q){ insert(1,0,SZ(lis),0,to[A[X[i]]],-X[i]); insert(1,0,SZ(lis),0,to[V[i]],X[i]); ans.pb(seg[1]); } return ans; }

Compilation message (stderr)

bubblesort2.cpp: In function 'void insert(ll, ll, ll, ll, ll, ll)':
bubblesort2.cpp:30:19: error: request for member 'erase' in 'ss[id]', which is of non-class type 'll' {aka 'long long int'}
   30 |   if(val<0)ss[id].erase(-val);else ss[id].insert(val);
      |                   ^~~~~
bubblesort2.cpp:30:43: error: request for member 'insert' in 'ss[id]', which is of non-class type 'll' {aka 'long long int'}
   30 |   if(val<0)ss[id].erase(-val);else ss[id].insert(val);
      |                                           ^~~~~~
bubblesort2.cpp:22:23: error: request for member 'size' in 'ss[id]', which is of non-class type 'll' {aka 'long long int'}
   22 | #define SZ(_a) (ll)_a.size()
      |                       ^~~~
bubblesort2.cpp:31:6: note: in expansion of macro 'SZ'
   31 |   if(SZ(ss[id])==0){
      |      ^~
bubblesort2.cpp:22:23: error: request for member 'size' in 'ss[id]', which is of non-class type 'll' {aka 'long long int'}
   22 | #define SZ(_a) (ll)_a.size()
      |                       ^~~~
bubblesort2.cpp:34:12: note: in expansion of macro 'SZ'
   34 |    cnt[id]=SZ(ss[id]);
      |            ^~
bubblesort2.cpp:35:24: error: no matching function for call to 'prev(ll&)'
   35 |    seg[id]=*prev(ss[id])-(count+(SZ(ss[id])-1));
      |                        ^
In file included from /usr/include/c++/9/bits/stl_algobase.h:66,
                 from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from bubblesort2.cpp:1:
/usr/include/c++/9/bits/stl_iterator_base_funcs.h:224:5: note: candidate: 'template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type)'
  224 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
/usr/include/c++/9/bits/stl_iterator_base_funcs.h:224:5: note:   template argument deduction/substitution failed:
/usr/include/c++/9/bits/stl_iterator_base_funcs.h: In substitution of 'template<class _BidirectionalIterator> _BidirectionalIterator std::prev(_BidirectionalIterator, typename std::iterator_traits<_Iter>::difference_type) [with _BidirectionalIterator = long long int]':
bubblesort2.cpp:35:24:   required from here
/usr/include/c++/9/bits/stl_iterator_base_funcs.h:224:5: error: no type named 'difference_type' in 'struct std::iterator_traits<long long int>'
bubblesort2.cpp:22:23: error: request for member 'size' in 'ss[id]', which is of non-class type 'll' {aka 'long long int'}
   22 | #define SZ(_a) (ll)_a.size()
      |                       ^~~~
bubblesort2.cpp:35:34: note: in expansion of macro 'SZ'
   35 |    seg[id]=*prev(ss[id])-(count+(SZ(ss[id])-1));
      |                                  ^~
bubblesort2.cpp: In function 'std::vector<long long int> countScans(std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
bubblesort2.cpp:51:2: error: 'n' was not declared in this scope
   51 |  n=SZ(A);q=SZ(X);
      |  ^
bubblesort2.cpp:51:10: error: 'q' was not declared in this scope
   51 |  n=SZ(A);q=SZ(X);
      |          ^