Submission #167218

#TimeUsernameProblemLanguageResultExecution timeMemory
167218rzbttrapezoid (balkan11_trapezoid)C++14
75 / 100
653 ms47372 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb push_back #define F first #define S second #define all(x) x.begin(),x.end() #define MAXN 100005 #define MOD 30013 typedef long long ll; using namespace std; int n; pair<pair<int,int>, pair<int,int> > niz[MAXN]; set<int> sg,sd; map<int,int> mg,md; pair<int,int> ubaci[2*MAXN],pitaj[2*MAXN]; pair<int,int> seg[8*MAXN]; pair<int,int> tres[MAXN]; pair<int,int> res; void dodaj(int l,int d,int p,int k,pair<int,int> x){ if(l==d){ seg[k]=x; return; } int mid=(l+d)/2; if(p<=mid)dodaj(l,mid,p,k+k,x); else dodaj(mid+1,d,p,k+k+1,x); if(seg[k+k].F==seg[k+k+1].F)seg[k]=mp(seg[k+k].F,(seg[k+k].S+seg[k+k+1].S)%MOD); else seg[k]=max(seg[k+k],seg[k+k+1]); //printf(" %d %d %d\n",k,seg[k].F,seg[k].S); } pair<int,int> dobij(int l,int d,int tl,int td,int k){ if(l>td || d<tl)return mp(0,0); if(l>=tl && d<=td)return seg[k]; int mid=(l+d)/2; auto levo=dobij(l,mid,tl,td,k+k); auto desno=dobij(mid+1,d,tl,td,k+k+1); //printf("%d %d\n",levo.F,desno.F); if(levo.F==desno.F)return mp(levo.F,(levo.S+desno.S)%MOD); return max(levo,desno); } int main() { scanf("%d", &n); for(int i=1;i<=n;i++){ int a,b,c,d; scanf("%d %d %d %d", &a, &b, &c, &d); niz[i]=mp(mp(a,b),mp(c,d)); sg.insert(a); sg.insert(b); sd.insert(c); sd.insert(d); } int brojac=1; for(auto x:sg){ mg[x]=brojac; brojac++; } brojac=1; for(auto x:sd){ md[x]=brojac; brojac++; } for(int i=1;i<=n;i++){ niz[i].F.F=mg[niz[i].F.F]; niz[i].F.S=mg[niz[i].F.S]; niz[i].S.F=md[niz[i].S.F]; niz[i].S.S=md[niz[i].S.S]; pitaj[niz[i].F.F]=mp(niz[i].S.F,i); ubaci[niz[i].F.S]=mp(niz[i].S.S,i); } for(int i=1;i<=n+n;i++){ //printf(" %d %d",seg[1]) if(pitaj[i].F){ pair<int,int> ans=dobij(1,n+n,1,pitaj[i].F,1); if(ans==mp(0,0))ans=mp(0,1); ans.F++; tres[pitaj[i].S]=ans; if(ans.F>res.F) res=ans; else if(ans.F==res.F) res.S+=ans.S; res.S%=MOD; }else{ dodaj(1,n+n,ubaci[i].F,1,tres[ubaci[i].S]); } } printf("%d %d",res.F,res.S); return 0; }

Compilation message (stderr)

trapezoid.cpp: In function 'int main()':
trapezoid.cpp:92:18: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
             else if(ans.F==res.F)
                  ^~
trapezoid.cpp:94:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
                 res.S%=MOD;
                 ^~~
trapezoid.cpp:52:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
trapezoid.cpp:55:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d %d", &a, &b, &c, &d);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...