Submission #1222738

#TimeUsernameProblemLanguageResultExecution timeMemory
1222738mariamtsagareli사다리꼴 (balkan11_trapezoid)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using i = int; using pii = pair<i,i>; const i MOD = 30013; struct Seg { i mx; i cnt; Seg(i m=0,i c=0):mx(m),cnt(c){} }; Seg merge(const Seg &a,const Seg &b){ if(a.mx>b.mx) return a; if(b.mx>a.mx) return b; if(a.mx==0) return Seg(0,1); return Seg(a.mx,(a.cnt+b.cnt)%MOD); } struct ST{ i n; vector<Seg> t; ST(i _n):n(_n),t(4*_n+4,Seg(0,1)){} Seg q(i p,i l,i r,i i,i j){ if(r<i||l>j) return Seg(0,1); if(i<=l&&r<=j) return t[p]; i m=(l+r)>>1; return merge(q(p<<1,l,m,i,j),q(p<<1|1,m+1,r,i,j)); } Seg q(i i,i j){return i>j?Seg(0,1):q(1,1,n,i,j);} void u(i p,i l,i r,i x,Seg v){ if(l==r){t[p]=merge(t[p],v);return;} i m=(l+r)>>1; if(x<=m) u(p<<1,l,m,x,v); else u(p<<1|1,m+1,r,x,v); t[p]=merge(t[p<<1],t[p<<1|1]); } void u(i x,Seg v){u(1,1,n,x,v);} }; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); i N;cin>>N; struct T{i a,b,c,d;}; vector<T> A(N); vector<i> X;X.reserve(4*N); for(i i=0;i<N;i++){cin>>A[i].a>>A[i].b>>A[i].c>>A[i].d;X.push_back(A[i].a);X.push_back(A[i].b);X.push_back(A[i].c);X.push_back(A[i].d);} sort(X.begin(),X.end());X.erase(unique(X.begin(),X.end()),X.end()); auto id=[&](i v){return (i)(lower_bound(X.begin(),X.end(),v)-X.begin()+1);}; i M=X.size(); for(auto &t:A){t.a=id(t.a);t.b=id(t.b);t.c=id(t.c);t.d=id(t.d);} sort(A.begin(),A.end(),[](const T &u,const T &v){return u.a!=v.a?u.a<v.a:u.b<v.b;}); ST ST1(M),ST2(M); vector<Seg> D(N); for(i i=0;i<N;i++){ Seg s1=ST1.q(1,A[i].a-1); Seg s2=ST2.q(1,A[i].c-1); Seg best=merge(s1,s2); D[i]=Seg(best.mx+1,best.cnt); ST1.u(A[i].b,D[i]); ST2.u(A[i].d,D[i]); } i res=0;for(auto &s:D)res=max(res,s.mx); i ways=0;for(auto &s:D)if(s.mx==res)ways=(ways+s.cnt)%MOD; cout<<res<<" "<<ways; }

Compilation message (stderr)

trapezoid.cpp:24:27: error: 'i' is not a type
   24 |     Seg q(i p,i l,i r,i i,i j){
      |                           ^
trapezoid.cpp:30:15: error: 'i' is not a type
   30 |     Seg q(i i,i j){return i>j?Seg(0,1):q(1,1,n,i,j);}
      |               ^
trapezoid.cpp: In member function 'Seg ST::q(i, i, i, i, int)':
trapezoid.cpp:27:11: error: expected ';' before 'm'
   27 |         i m=(l+r)>>1;
      |           ^
trapezoid.cpp:28:31: error: 'm' was not declared in this scope; did you mean 'tm'?
   28 |         return merge(q(p<<1,l,m,i,j),q(p<<1|1,m+1,r,i,j));
      |                               ^
      |                               tm