Submission #1029560

#TimeUsernameProblemLanguageResultExecution timeMemory
1029560vjudge1Wish (LMIO19_noras)C++17
93 / 100
115 ms18872 KiB
// 23 - 12 - 23 #include<bits/stdc++.h> using namespace std; #define read() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) #define day() time_t now = time(0);char* x = ctime(&now);cerr<<"Right Now Is : "<<x<<"\n" #define int long long #define ii pair<int,int> #define X first #define Y second const long long MAX = (int)2e5 + 5; const long long INF = (int)1e9; const long long MOD = (int)1e9 + 7; int n,r; int a[MAX],b[MAX],c[MAX],d[MAX]; signed main(){ read(); cin >> n >> r; // (x) ^ 2 + y ^ 2 = r ^ 2 // a[i] + t * u , b[i] + t * v // (a + tu) ^ 2 + (b + tv) ^ 2 = r // t ^ 2 * (u ^ 2 + v ^ 2) + 2t(au + bv) + a ^ 2 + b ^ 2 - r ^ 2 = 0 vector<ii> sweep; for(int i = 1;i <= n;i++){ cin >> a[i] >> b[i] >> c[i] >> d[i]; int u = c[i] - a[i]; int v = d[i] - b[i]; int _a = u * u + v * v; int _b = 2 * (a[i] * u + b[i] * v); int _c = a[i] * a[i] + b[i] * b[i] - r * r; // _aX^2 + _bX + _c = 0 int dental = _b * _b - 4 * _a * _c; if(dental >= 0){ long double x_1 = (-_b - sqrt(dental)) / (2 * _a); long double x_2 = (-_b + sqrt(dental)) / (2 * _a); int inside = ceil(min(x_1,x_2)); int outside = floor(max(x_2,x_1)); if(inside <= outside){ //cout << i << " " << inside << " " << outside << "\n"; sweep.push_back({inside,0}); sweep.push_back({outside,1}); } } } sort(sweep.begin(),sweep.end(),[&](const ii &a,const ii &b){ return (a.X == b.X) ? (a.Y < b.Y) : (a.X < b.X); }); int res = 0; int cnt = 0; for(auto e : sweep){ if(e.X >= 0) res = max(res,cnt); cnt += (e.Y == 0 ? 1 : -1); } cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...