답안 #1039388

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1039388 2024-07-30T19:40:43 Z 1L1YA 사다리꼴 (balkan11_trapezoid) C++17
100 / 100
120 ms 32448 KB
//1L1YA

#include<bits/stdc++.h>
using namespace std;

//#pragma GCC optimize ("O3,unrool-loops")
//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

typedef long long       ll;
typedef pair<ll,ll>     pll;
typedef pair<int,int>   pii;

#define Pb              push_back
#define F               first
#define S               second
#define endl            '\n'
#define sep             ' '
#define all(x)          x.begin(),x.end()
#define al(x,n)         x+1,x+n+1
#define SZ(x)           ((int)x.size())
#define lc              (id<<1)
#define rc              (lc|1)
#define mid             (l+r>>1)
#define dokme(x)        cout << x << endl, exit(0)
#define sik(x)          cout << x << endl;continue;
#define FastIO          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FileIO          freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll oo=1e18;
const int mod=30013;
const int inf=1e9+111;
const int N=1e5+11;
const int lg=23;

int n,m,a[N],b[N],c[N],d[N];
pii dp[N],fen[N<<2];
vector<int> vc1[N<<2],vc2[N<<2];

void upd(int x,pii y){
	for(;x<=m;x+=x&-x)
		if(y.F>fen[x].F)	fen[x]=y;
		else if(y.F==fen[x].F)	fen[x].S+=y.S,fen[x].S%=mod;
}

pii get(int x){
	pii ans={0,1};
	for(;x;x-=x&-x)
		if(fen[x].F>ans.F)	ans=fen[x];
		else if(fen[x].F==ans.F)	ans.S+=fen[x].S,ans.S%=mod;
	return ans;
}

int main(){
	FastIO

	cin >> n;
	vector<int> comp;
	for(int i=1;i<=n;i++){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		comp.Pb(a[i]);comp.Pb(b[i]);comp.Pb(c[i]);comp.Pb(d[i]);
	}
	sort(all(comp));
	comp.resize(unique(all(comp))-comp.begin());
	m=SZ(comp);
	for(int i=1;i<=n;i++){
		a[i]=lower_bound(all(comp),a[i])-comp.begin()+1;
		b[i]=lower_bound(all(comp),b[i])-comp.begin()+1;
		c[i]=lower_bound(all(comp),c[i])-comp.begin()+1;
		d[i]=lower_bound(all(comp),d[i])-comp.begin()+1;
		vc1[a[i]].Pb(i);
		vc2[b[i]].Pb(i);
	}
	for(int i=1;i<=m;i++)	fen[i]={0,0};
	for(int i=1;i<=m;i++){
		for(int j: vc1[i])	dp[j]=get(c[j]-1),dp[j].F++;
		for(int j: vc2[i])	upd(d[j],dp[j]);
	}
	cout << get(m).F << sep << get(m).S << endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 23132 KB Output is correct
2 Correct 3 ms 23164 KB Output is correct
3 Correct 4 ms 23132 KB Output is correct
4 Correct 4 ms 23132 KB Output is correct
5 Correct 5 ms 23388 KB Output is correct
6 Correct 6 ms 23376 KB Output is correct
7 Correct 7 ms 23388 KB Output is correct
8 Correct 8 ms 23500 KB Output is correct
9 Correct 13 ms 24028 KB Output is correct
10 Correct 21 ms 25052 KB Output is correct
11 Correct 26 ms 25500 KB Output is correct
12 Correct 51 ms 27708 KB Output is correct
13 Correct 72 ms 28672 KB Output is correct
14 Correct 78 ms 29644 KB Output is correct
15 Correct 81 ms 30012 KB Output is correct
16 Correct 87 ms 30632 KB Output is correct
17 Correct 105 ms 31128 KB Output is correct
18 Correct 85 ms 31428 KB Output is correct
19 Correct 98 ms 31972 KB Output is correct
20 Correct 120 ms 32448 KB Output is correct