답안 #912352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912352 2024-01-19T10:14:31 Z vjudge1 Wish (LMIO19_noras) C++17
0 / 100
2 ms 6620 KB
#include <bits/stdc++.h>
#define f first
#define s second	
#define ent '\n'
#define int long long

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")

using namespace std;
typedef long long ll;
const int mx=1e6+12;
const int mod=1e9+7;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};

map<int,int> pref;
int L[mx];
int R[mx];
int x[mx];
int y[mx];
int a[mx];
int b[mx];
int n,m,k;

bool check(int x,int y){
	if(max(x,y)>k)return 0;
	return x*x+y*y<=k*k;
}

bool check(__int128 x1,__int128 y1,__int128 x2,__int128 y2){
	__int128 val=(__int128)x1*(__int128)x1+(__int128)y1*(__int128)y1;
	__int128 cal=(__int128)x2*(__int128)x2+(__int128)y2*(__int128)y2;
	if(val>=cal)return 1;
	return 0;
}

void Press_Fn_with_F11(){
	cin>>n>>k;
	int ans=0;
	for(int i=1;i<=n;i++){
		cin>>x[i]>>y[i]>>a[i]>>b[i];
		a[i]-=x[i];
		b[i]-=y[i];
		int l=0,r=2e9,pos0=0;
		while(r-l>10){
			int m1=l+(r-l)/3,m2=r-(r-l)/3;
			if(check(x[i]+m1*a[i],y[i]+m1*b[i],x[i]+m2*a[i],y[i]+m2*b[i])){
				l=m1;
			}
			else r=m2;
		}
		pos0=l;
		for(int v=l+1;v<=r;v++){
			if(check(pos0*a[i]+x[i],pos0*b[i]+y[i],v*a[i]+x[i],v*b[i]+y[i])){
				pos0=v;
			}
		}
		if(!check(x[i]+pos0*a[i],y[i]+pos0*b[i])){
			continue;
		}
		int L=pos0,R=pos0;
		for(int l=0,r=pos0;l<=r;){
			int mid=l+r>>1ll;
			if(check((__int128)mid*a[i]+x[i],(__int128)mid*b[i]+y[i])){
				L=mid;
				r=mid-1;
			}
			else l=mid+1;
		}
		for(int l=pos0,r=2e9;l<=r;){
			int mid=l+r>>1ll;
			if(check((__int128)mid*a[i]+x[i],(__int128)mid*b[i]+y[i])){
				R=mid;
				l=mid+1;
			}
			else r=mid-1;
		}
		pref[L]++;
		pref[R+1]--;
	}
	int v=0;
	for(auto x:pref){
		v+=x.s;
		ans=max(ans,v);
	}
	cout<<ans<<ent;
	
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int Alikhan_abi_crush=1;
	// cin>>Alikhan_abi_crush;
	while(Alikhan_abi_crush--){
		Press_Fn_with_F11();
	}
}

Compilation message

noras.cpp: In function 'void Press_Fn_with_F11()':
noras.cpp:64:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   64 |    int mid=l+r>>1ll;
      |            ~^~
noras.cpp:72:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   72 |    int mid=l+r>>1ll;
      |            ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 2 ms 6620 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 2 ms 6620 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 2 ms 6620 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 2 ms 6620 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 6492 KB Output is correct
2 Correct 2 ms 6492 KB Output is correct
3 Incorrect 2 ms 6620 KB Output isn't correct
4 Halted 0 ms 0 KB -