This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n;
vector<pii> segment;
double r,A,B,C,D,vA,vB;
cin >> n >> r;
for(int i=1;i<=n;i++){
cin >> A >> B >> C >> D;
vA=C-A;vB=D-B;
if(A!=C){
double m=(D-B)/(C-A);
double c=B-m*A;
double disk=m*m*c*c-(m*m+1.0)*(c*c-r*r);
if(disk<0.0)continue;
disk=sqrt(disk);
double x1=(-1.0*m*c+disk)/(m*m+1.0),x2=(-1.0*m*c-disk)/(m*m+1.0);
double time1=(x1-A)/vA+1.0,time2=(x2-A)/vA+1.0;
if(time2<time1)swap(time1,time2);
if(time2<1.0)continue;
if(time1<1.0)time1=1.0;
int masuk=(int)ceil(time1),keluar=(int)floor(time2)+1;
if(keluar>masuk){
segment.push_back({masuk,i});
segment.push_back({keluar,-i});
}
}
else{
double val=r*r-A*A;
if(val<0.0)continue;
val=sqrt(val);
double y1=-1.0*val,y2=val;
double time1=(y1-B)/vB+1.0,time2=(y2-B)/vB+1.0;
if(time2<time1)swap(time1,time2);
if(time2<1.0)continue;
if(time1<1.0)time1=1.0;
int masuk=(int)ceil(time1),keluar=(int)floor(time2)+1;
if(keluar>masuk){
segment.push_back({masuk,i});
segment.push_back({keluar,-i});
}
}
}
sort(segment.begin(),segment.end());
int ans=0,active=0;
for(auto isi : segment){
if(isi.second>0)active++;
else active--;
ans=max(ans,active);
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |