Submission #72207412


Source Code Expand

#include<bits/stdc++.h>
#define M 200005
#define lowbit(x) x&(-x)
using namespace std;
struct node{
	int x,y;
	bool operator <(const node &_)const{
		return x<_.x;
	}
}A[M];
int B[M];
void check_max(int &x,int y){
	if(x<y)x=y;
}
struct Bin{
	int num[M];
	void Clear(){
		memset(num,0,sizeof(num));
	}
	void Add(int x,int d){
		x++;
		while(x<M){
			check_max(num[x],d);
			x+=lowbit(x); 
		}
	}
	int Query(int x){
		x++;
		int res=0;
		while(x){
			check_max(res,num[x]); 
			x-=lowbit(x);
		}
		return res;
	}
}BT;
int dp[M];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&A[i].x,&A[i].y);
	for(int i=1;i<=n;i++)B[i]=A[i].x;
	sort(B+1,B+n+1);
	int sz=unique(B+1,B+n+1)-B-1;
	for(int i=1;i<=n;i++)A[i].x=lower_bound(B+1,B+sz+1,A[i].x)-B;
	
	for(int i=1;i<=n;i++)B[i]=A[i].y;
	sort(B+1,B+n+1);
	sz=unique(B+1,B+n+1)-B-1;
	for(int i=1;i<=n;i++)A[i].y=lower_bound(B+1,B+sz+1,A[i].y)-B;
	sort(A+1,A+n+1);
	int ans=0;
	BT.Clear();
	for(int i=1;i<=n;i++){
		int j=i;
		while(j<n&&A[j+1].x==A[i].x)j++;
		for(int k=i;k<=j;k++){
			dp[k]=BT.Query(A[k].y-1)+1;
			check_max(ans,dp[k]);
		}
		for(int k=i;k<=j;k++){
			BT.Add(A[k].y,dp[k]);
		}
		i=j;
	}
	printf("%d\n",ans);
	return 0;
}

Submission Info

Submission Time
Task E - Kite
User Hacker_
Language C++23 (GCC 15.2.0)
Score 450
Code Size 1271 Byte
Status AC
Exec Time 112 ms
Memory 7872 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 450 / 450
Status
AC × 3
AC × 24
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_1_00.txt, 01_random_1_01.txt, 01_random_1_02.txt, 01_random_1_03.txt, 01_random_1_04.txt, 01_random_1_05.txt, 02_random_2_00.txt, 02_random_2_01.txt, 02_random_2_02.txt, 02_random_2_03.txt, 02_random_2_04.txt, 02_random_2_05.txt, 03_sorted_00.txt, 03_sorted_01.txt, 03_sorted_02.txt, 03_sorted_03.txt, 03_sorted_04.txt, 03_sorted_05.txt, 04_same_coord_00.txt, 04_same_coord_01.txt, 04_same_coord_02.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 2 ms 4452 KiB
00_sample_01.txt AC 1 ms 4672 KiB
00_sample_02.txt AC 1 ms 4456 KiB
01_random_1_00.txt AC 65 ms 6360 KiB
01_random_1_01.txt AC 112 ms 7696 KiB
01_random_1_02.txt AC 92 ms 7276 KiB
01_random_1_03.txt AC 112 ms 7844 KiB
01_random_1_04.txt AC 111 ms 7640 KiB
01_random_1_05.txt AC 112 ms 7592 KiB
02_random_2_00.txt AC 107 ms 7720 KiB
02_random_2_01.txt AC 108 ms 7636 KiB
02_random_2_02.txt AC 109 ms 7748 KiB
02_random_2_03.txt AC 108 ms 7636 KiB
02_random_2_04.txt AC 106 ms 7636 KiB
02_random_2_05.txt AC 107 ms 7720 KiB
03_sorted_00.txt AC 107 ms 7872 KiB
03_sorted_01.txt AC 108 ms 7592 KiB
03_sorted_02.txt AC 106 ms 7776 KiB
03_sorted_03.txt AC 106 ms 7668 KiB
03_sorted_04.txt AC 107 ms 7720 KiB
03_sorted_05.txt AC 107 ms 7748 KiB
04_same_coord_00.txt AC 68 ms 7696 KiB
04_same_coord_01.txt AC 76 ms 7652 KiB
04_same_coord_02.txt AC 33 ms 7668 KiB