#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define ent "\n"
const int inf = (int)1e9 + 100;
const int maxn = 5e5 + 100;
const ll INF = (ll)1e18;
const int MOD = 1e9 + 7;
const int maxl = 62500;
const ll P = 31, T = 0;
ll n, R;
ll a[maxn];
ll b[maxn];
ll c[maxn];
ll d[maxn];
bool ok(ll x, ll y){
if(max(abs(x), abs(y)) > R) return 0;
return x * x + y * y <= R * R;
}
void test(){
cin >> n >> R;
for(int i = 1; i <= n; i++){
cin >> a[i] >> b[i] >> c[i] >> d[i];
c[i] -= a[i]; d[i] -= b[i];
if(a[i] < 0) a[i] *= -1, c[i] *= -1;
if(b[i] < 0) b[i] *= -1, d[i] *= -1;
}
vector<pll> v;
for(int i = 1; i <= n; i++){
ll s = -1;
if(ok(a[i], b[i])){
s = 0;
} else{
for(ll l = 0, r = 1e6; l <= r;){
ll mid = (l + r) >> 1;
ll x = a[i] + c[i] * mid;
ll y = b[i] + d[i] * mid;
if(ok(x, y)){
s = mid; r = mid - 1;
} else if(x + y < 0) r = mid - 1;
else l = mid + 1;
}
}
if(s != -1){
ll t = -1;
for(ll l = s, r = 1e6; l <= r;){
ll mid = (l + r) >> 1;
ll x = a[i] + c[i] * mid;
ll y = b[i] + d[i] * mid;
if(ok(x, y)){
t = mid; l = mid + 1;
} else r = mid - 1;
}
v.push_back({s, 1});
v.push_back({t+1, -1});
}
}
int ans = 0, cnt = 0;
sort(v.begin(), v.end());
for(int i = 0; i < v.size();){
int j = i;
while(j < v.size() && v[j].first == v[i].first){
cnt += v[j].second; j++;
}
ans = max(ans, cnt);
i = j;
}
cout << ans;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// #endif
int t = 1;
if(T) cin >> t;
while(t--) test();
}
Compilation message
noras.cpp: In function 'void test()':
noras.cpp:66:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | for(int i = 0; i < v.size();){
| ~~^~~~~~~~~~
noras.cpp:68:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | while(j < v.size() && v[j].first == v[i].first){
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
2 ms |
6492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
2 ms |
6492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
2 ms |
6492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
2 ms |
6492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
6492 KB |
Output is correct |
2 |
Correct |
1 ms |
6492 KB |
Output is correct |
3 |
Incorrect |
2 ms |
6492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |