Submission #290131

#TimeUsernameProblemLanguageResultExecution timeMemory
290131TadijaSebezSweeping (JOI20_sweeping)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define pii pair<int,int> struct Query{ int type; int idx,x,y; int l; Query(){} Query(int t,int i,int X,int Y):type(t),idx(i),x(X),y(Y),l(-1){} Query(int t,int i,int L):type(t),idx(i),l(L),x(-1),y(-1){} }; const int N=1500050; const int M=2*N*30; pii ans[N]; int n,m,q; int val[M],myc[N*2],tsz,rem[N]; vector<int> cmp[M]; int add(int i,int v){tsz++;val[tsz]=v;myc[i]=tsz;cmp[tsz]={i};return tsz;} int mrg(int a,int b){ if(cmp[a].size()>cmp[b].size())swap(a,b); for(int i:cmp[a]){ myc[i]=b; cmp[b].pb(i); } cmp[a].clear(); return b; } void DNC(int l,int r,vector<Query> Qs){ if(Qs.empty())return; int mid=l+r>>1; int X=mid,Y=n-mid; priority_queue<pii> xs,ys; vector<Query> LQ,RQ; for(Query qu:Qs){ if(qu.type==1){ int x=val[myc[qu.idx<<1]],y=val[myc[qu.idx<<1|1]]; if(rem[qu.idx]==1)RQ.pb(qu); else if(rem[qu.idx]==2)LQ.pb(qu); else ans[qu.l]={x,y}; }else if(qu.type==2){ if(qu.l<Y){ RQ.pb(qu); while(ys.size()&&-ys.top().first<=qu.l){ int c=ys.top().second; ys.pop(); for(int i:cmp[c])if(!rem[i/2]){ int x=n-qu.l,y=val[c]; RQ.pb(Query(4,i/2,x,y)); rem[i/2]=1; } } }else{ int now=0; while(xs.size()&&-xs.top().first<n-qu.l){ int tmp=xs.top().second; xs.pop(); now=now?mrg(now,tmp):tmp; } if(now)val[now]=n-qu.l,xs.push({-val[now],now}); LQ.pb(qu); } }else if(qu.type==3){ if(qu.l<X){ LQ.pb(qu); while(xs.size()&&-xs.top().first<=qu.l){ int c=xs.top().second; xs.pop(); for(int i:cmp[c])if(!rem[i/2]){ int x=val[c],y=n-qu.l; LQ.pb(Query(4,i/2,x,y)); rem[i/2]=2; } } }else{ int now=0; while(ys.size()&&-ys.top().first<n-qu.l){ int tmp=ys.top().second; ys.pop(); now=now?mrg(now,tmp):tmp; } if(now)val[now]=n-qu.l,ys.push({-val[now],now}); RQ.pb(qu); } }else{ if(qu.x>X)rem[qu.idx]=1,RQ.pb(qu); else if(qu.y>Y)rem[qu.idx]=2,LQ.pb(qu); else{ rem[qu.idx]=0; xs.push({-qu.x,add(qu.idx<<1,qu.x)}); ys.push({-qu.y,add(qu.idx<<1|1,qu.y)}); } } } if(l==r)return; if(l+1==r)DNC(r,r,RQ); else{ DNC(l,mid,LQ); DNC(mid,r,RQ); } } int main(){ scanf("%i %i %i",&n,&m,&q); vector<Query> Qs; for(int i=1,x,y;i<=m;i++){ scanf("%i %i",&x,&y); Qs.pb(Query(4,i,x,y)); } int z=0; for(int i=1;i<=q;i++){ int t;scanf("%i",&t); if(t==1){ int idx;scanf("%i",&idx); Qs.pb(Query(1,idx,++z)); }else if(t==2||t==3){ int l;scanf("%i",&l); Qs.pb(Query(t,-1,l)); }else{ int x,y;scanf("%i %i",&x,&y); Qs.pb(Query(4,++m,x,y)); } } DNC(0,n,Qs); for(int i=1;i<=z;i++)printf("%i %i\n",ans[i].first,ans[i].second); return 0; }

Compilation message (stderr)

sweeping.cpp: In constructor 'Query::Query(int, int, int)':
sweeping.cpp:8:6: warning: 'Query::l' will be initialized after [-Wreorder]
    8 |  int l;
      |      ^
sweeping.cpp:7:10: warning:   'int Query::x' [-Wreorder]
    7 |  int idx,x,y;
      |          ^
sweeping.cpp:11:2: warning:   when initialized here [-Wreorder]
   11 |  Query(int t,int i,int L):type(t),idx(i),l(L),x(-1),y(-1){}
      |  ^~~~~
sweeping.cpp: In function 'void DNC(int, int, std::vector<Query>)':
sweeping.cpp:31:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   31 |  int mid=l+r>>1;
      |          ~^~
sweeping.cpp: In function 'int main()':
sweeping.cpp:103:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  103 |  scanf("%i %i %i",&n,&m,&q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
sweeping.cpp:106:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  106 |   scanf("%i %i",&x,&y);
      |   ~~~~~^~~~~~~~~~~~~~~
sweeping.cpp:111:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  111 |   int t;scanf("%i",&t);
      |         ~~~~~^~~~~~~~~
sweeping.cpp:113:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  113 |    int idx;scanf("%i",&idx);
      |            ~~~~~^~~~~~~~~~~
sweeping.cpp:116:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  116 |    int l;scanf("%i",&l);
      |          ~~~~~^~~~~~~~~
sweeping.cpp:119:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  119 |    int x,y;scanf("%i %i",&x,&y);
      |            ~~~~~^~~~~~~~~~~~~~~
/tmp/ccb8eGkc.o: In function `add(int, int)':
sweeping.cpp:(.text+0x42): relocation truncated to fit: R_X86_64_PC32 against symbol `tsz' defined in .bss section in /tmp/ccb8eGkc.o
sweeping.cpp:(.text+0x4e): relocation truncated to fit: R_X86_64_PC32 against symbol `tsz' defined in .bss section in /tmp/ccb8eGkc.o
sweeping.cpp:(.text+0x59): relocation truncated to fit: R_X86_64_32S against symbol `myc' defined in .bss section in /tmp/ccb8eGkc.o
sweeping.cpp:(.text+0x65): relocation truncated to fit: R_X86_64_32S against symbol `val' defined in .bss section in /tmp/ccb8eGkc.o
sweeping.cpp:(.text+0xbc): relocation truncated to fit: R_X86_64_PC32 against symbol `tsz' defined in .bss section in /tmp/ccb8eGkc.o
/tmp/ccb8eGkc.o: In function `mrg(int, int)':
sweeping.cpp:(.text+0x1c2): relocation truncated to fit: R_X86_64_32S against symbol `myc' defined in .bss section in /tmp/ccb8eGkc.o
/tmp/ccb8eGkc.o: In function `DNC(int, int, std::vector<Query, std::allocator<Query> >)':
sweeping.cpp:(.text+0x270): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccb8eGkc.o
sweeping.cpp:(.text+0x33d): relocation truncated to fit: R_X86_64_32S against symbol `rem' defined in .bss section in /tmp/ccb8eGkc.o
sweeping.cpp:(.text+0x3a5): relocation truncated to fit: R_X86_64_32S against symbol `rem' defined in .bss section in /tmp/ccb8eGkc.o
sweeping.cpp:(.text+0x3c8): relocation truncated to fit: R_X86_64_32S against symbol `myc' defined in .bss section in /tmp/ccb8eGkc.o
sweeping.cpp:(.text+0x3d3): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status