#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];
vector<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.pb(a);
sg.pb(b);
sd.pb(c);
sd.pb(d);
}
sort(all(sg));
int brojac=1;
for(auto x:sg){
mg[x]=brojac;
brojac++;
}
sort(all(sd));
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
trapezoid.cpp: In function 'int main()':
trapezoid.cpp:94:18: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
else if(ans.F==res.F)
^~
trapezoid.cpp:96: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 time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Correct |
4 ms |
632 KB |
Output is correct |
5 |
Correct |
6 ms |
888 KB |
Output is correct |
6 |
Correct |
8 ms |
1272 KB |
Output is correct |
7 |
Correct |
11 ms |
1528 KB |
Output is correct |
8 |
Correct |
15 ms |
1912 KB |
Output is correct |
9 |
Correct |
28 ms |
3448 KB |
Output is correct |
10 |
Correct |
64 ms |
6520 KB |
Output is correct |
11 |
Correct |
84 ms |
7796 KB |
Output is correct |
12 |
Correct |
193 ms |
15424 KB |
Output is correct |
13 |
Correct |
258 ms |
17900 KB |
Output is correct |
14 |
Correct |
287 ms |
22496 KB |
Output is correct |
15 |
Correct |
334 ms |
23808 KB |
Output is correct |
16 |
Correct |
373 ms |
25188 KB |
Output is correct |
17 |
Correct |
379 ms |
26464 KB |
Output is correct |
18 |
Correct |
362 ms |
27616 KB |
Output is correct |
19 |
Correct |
384 ms |
28008 KB |
Output is correct |
20 |
Correct |
438 ms |
30052 KB |
Output is correct |