Submission #1032018

#TimeUsernameProblemLanguageResultExecution timeMemory
1032018boyliguanhanBubble Sort 2 (JOI18_bubblesort2)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define N 1<<20 pair<int,int>val[N]; int lz[2*N],vl[2*N],Cc; int read(){ int x=0; char c=getchar(); while(c<48||c>57) c=getchar(); while(c>47&&c<58) x=x*10+c-48,c=getchar(); return x; } void pd(int n){ if(n<N)lz[2*n]+=lz[n], lz[2*n+1]+=lz[n]; vl[n]+=lz[n]; lz[n]=0; } void upd(int i,int l,int r,int ll,int rr,int v){ pd(i); if(ll>r||l>rr)return; if(ll<=l&&r<=rr) return lz[i]+=v,pd(i); upd(i*2,l,l+r>>1,ll,rr,v); upd(i*2+1,l+r+2>>1,r,ll,rr,v); vl[i]=max(vl[i*2],vl[i*2+1]); } signed main(){ int n(read()),q(read()); vector<long long>A(n),X(q),V(q); map<long long,int>mp; for(auto&i:A)i=read(); for(int i=0;i<q;i++) X[i]=read(),V[i]=read(), mp[V[i]*n+X[i]]; for(int i=0;i<n;i++) mp[i+n*A[i]]; for(auto&i:mp) i.second=++Cc; int sz=mp.size(); for(int i=0;i<q;i++) V[i]=mp[V[i]*n+X[i]]; for(int i=0;i<n;i++) { A[i]=mp[i+n*A[i]]; upd(1,1,sz,A[i]+1,sz,-1); upd(1,1,sz,A[i],A[i],i); } for(int i=0;i<q;i++){ int k=X[i]; int v=V[i]; upd(1,1,sz,A[k]+1,sz,1), upd(1,1,sz,A[k],A[k],-k); A[k]=v; upd(1,1,sz,A[k]+1,sz,-1), upd(1,1,sz,A[k],A[k],k); cout<<vl[1]<<'\n'; } }

Compilation message (stderr)

bubblesort2.cpp: In function 'void upd(int, int, int, int, int, int)':
bubblesort2.cpp:25:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   25 |     upd(i*2,l,l+r>>1,ll,rr,v);
      |               ~^~
bubblesort2.cpp:26:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |     upd(i*2+1,l+r+2>>1,r,ll,rr,v);
      |               ~~~^~
/usr/bin/ld: /tmp/ccy8gjdn.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccA8HKWp.o:bubblesort2.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccy8gjdn.o: in function `main':
grader.cpp:(.text.startup+0x181): undefined reference to `countScans(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status