#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define INFLL 1000000000000000000ll
#define EPS 1e-15L
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define fi first
#define sc second
using i64 = long long;
using u64 = unsigned long long;
using ld = long double;
using ii = pair<int, int>;
#define double ld
int n, radius;
bool good(i64 x, i64 y) {
if(max(abs(x), abs(y)) > INF) return false;
return x*x+y*y<=1ll*radius*radius;
}
double closest(int a, int b, int c, int d) {
if(1ll*a*a+1ll*b*b <= 1ll * radius*radius) return 0;
return max(0.0L, (-1ll * a * c - 1ll * b * d) / double(1ll*c*c+1ll*d*d));
}
int firstSec(int a, int b, int c, int d, double k) {
int l = 0, r = k;
while(l < r) {
int m = (l + r) / 2;
i64 x = a + m * c, y = b + m * d;
if(good(x,y)) r = m;
else l = m + 1;
}
return r;
}
int secondSec(int a, int b, int c, int d, double k) {
int l = ceil(k), r = 1e9;
while(l < r) {
int m = (l + r) / 2;
i64 x = a + m * c, y = b + m * d;
if(!good(x,y)) r = m;
else l = m + 1;
}
return r - 1;
}
void solve() {
cin >> n >> radius;
set<ii> sweep;
int opening = 0, ans = 0;
for(int i = 1; i <= n; ++i) {
int a, b, c, d;
cin >> a >> b >> c >> d;
c -= a, d -= b;
double k = closest(a, b, c, d);
int k1 = floor(k), k2 = ceil(k);
if(abs(k) > INF || (!good(a+1ll*k1*c,b+1ll*k1*d) && !good(a+1ll*k2*c,b+1ll*k2*d))) continue;
int l = firstSec(a, b, c, d, k);
int r = secondSec(a, b, c, d, k);
if(l > r) continue;
sweep.emplace(l, -i);
sweep.emplace(r, i);
}
for(auto [x, k] : sweep) {
opening += k < 0 ? 1 : -1;
ans = max(ans, opening);
}
cout << ans << '\n';
}
int main() {
ios_base :: sync_with_stdio(false);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--) solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |