#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define TSTS int ttt; cin >> ttt; while(ttt--) solve()
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sz(x) int((x).size())
using namespace std;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pdd;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
const int INF=1e9, MOD=1e9+7, mod=98244353;
const long long LINF=1e8;
void setIO()
{
FAST_IO;
}
void setIO(string s)
{
FAST_IO;
freopen((s+".in").c_str(), "r", stdin);
freopen((s+".out").c_str(), "w", stdout);
}
const int N=2e5+10;
ll n, R;
pair<ll, ll> ini[N], add[N];
ll sq(ll x){return x*x;}
pair<ll, ll> getPos(int in, ll t)
{
return {ini[in].F+add[in].F*t, ini[in].S+add[in].S*t};
}
ll calcDist(pair<ll, ll> pos)
{
if(abs(pos.F)>INF||abs(pos.S)>INF) return -1;
return sq(pos.F)+sq(pos.S);
}
ll getLow(int in)
{
//davai patikrini po to shita shuda
ll l=-1, r=LINF;
while(l<r-1){
ll m1=(l+r)/2, m2=m1+1;
pair<ll, ll> pos1=getPos(in, m1), pos2=getPos(in, m2);
ll v1=calcDist(pos1), v2=calcDist(pos2);
if(v1<0||v2<0){
r=m1;
continue;
}
if(v1<=v2) r=m1;
else l=m1;
}
return l+1;
}
ll lbound(int in, ll x)
{
ll l=0, r=x;
while(l<r){
ll m=(l+r)/2;
pair<ll, ll> pos=getPos(in, m); ll dist=calcDist(pos);
if(dist<0){
r=m;
continue;
}
if(dist>R*R) l=m+1;
else r=m;
}
return l;
}
ll rbound(int in, ll x)
{
ll l=x, r=LINF;
while(l<r){
ll m=(l+r+1)/2;
pair<ll, ll> pos=getPos(in, m); ll dist=calcDist(pos);
if(dist<0){
r=m-1;
continue;
}
if(dist>R*R) r=m-1;
else l=m;
}
return l;
}
int main()
{
setIO();
cin >> n >> R;
ll now=0;
FOR(i, 0, n)
{
ll aa, bb, cc, dd;
cin >> aa >> bb >> cc >> dd;
ini[i]={aa, bb}; add[i]={cc-aa, dd-bb};
}
vector<pair<ll, int>> inf;
FOR(i, 0, n)
{
ll low=getLow(i);
pair<ll, ll> pos=getPos(i, low); ll dist=sq(pos.F)+sq(pos.S);
if(dist>R*R) continue;
int l=lbound(i, low), r=rbound(i, low);
inf.PB({l, 1}); inf.PB({r+1, -1});
}
sort(inf.begin(), inf.end());
ll ans=0;
for(auto[x, y] : inf){
now+=y;
ans=max(ans, now);
}
cout << ans;
}
/*
TESTINGAS:
3 1
0 0 100000 0
0 0 0 0
0 0 0 0
*/
Compilation message
noras.cpp: In function 'void setIO(std::string)':
noras.cpp:31:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
31 | freopen((s+".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
noras.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
32 | freopen((s+".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
62 ms |
7632 KB |
Output is correct |
24 |
Correct |
69 ms |
7620 KB |
Output is correct |
25 |
Correct |
61 ms |
7632 KB |
Output is correct |
26 |
Correct |
60 ms |
7596 KB |
Output is correct |
27 |
Correct |
56 ms |
5572 KB |
Output is correct |
28 |
Correct |
78 ms |
7612 KB |
Output is correct |
29 |
Correct |
65 ms |
7692 KB |
Output is correct |
30 |
Correct |
62 ms |
7580 KB |
Output is correct |
31 |
Correct |
60 ms |
7616 KB |
Output is correct |
32 |
Correct |
81 ms |
7636 KB |
Output is correct |
33 |
Correct |
88 ms |
7704 KB |
Output is correct |
34 |
Correct |
81 ms |
7680 KB |
Output is correct |
35 |
Correct |
81 ms |
7624 KB |
Output is correct |
36 |
Correct |
96 ms |
7676 KB |
Output is correct |
37 |
Correct |
59 ms |
5640 KB |
Output is correct |
38 |
Correct |
62 ms |
5580 KB |
Output is correct |
39 |
Correct |
60 ms |
5636 KB |
Output is correct |
40 |
Correct |
68 ms |
5636 KB |
Output is correct |
41 |
Correct |
58 ms |
5568 KB |
Output is correct |
42 |
Correct |
59 ms |
5568 KB |
Output is correct |
43 |
Correct |
174 ms |
14804 KB |
Output is correct |
44 |
Correct |
186 ms |
14896 KB |
Output is correct |
45 |
Correct |
198 ms |
14844 KB |
Output is correct |
46 |
Correct |
178 ms |
14900 KB |
Output is correct |
47 |
Correct |
181 ms |
14912 KB |
Output is correct |
48 |
Correct |
169 ms |
14996 KB |
Output is correct |
49 |
Correct |
161 ms |
14892 KB |
Output is correct |
50 |
Correct |
157 ms |
14892 KB |
Output is correct |
51 |
Correct |
154 ms |
14816 KB |
Output is correct |
52 |
Correct |
162 ms |
14872 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
0 ms |
332 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
1 ms |
332 KB |
Output is correct |
26 |
Correct |
1 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
62 ms |
7632 KB |
Output is correct |
24 |
Correct |
69 ms |
7620 KB |
Output is correct |
25 |
Correct |
61 ms |
7632 KB |
Output is correct |
26 |
Correct |
60 ms |
7596 KB |
Output is correct |
27 |
Correct |
56 ms |
5572 KB |
Output is correct |
28 |
Correct |
78 ms |
7612 KB |
Output is correct |
29 |
Correct |
65 ms |
7692 KB |
Output is correct |
30 |
Correct |
62 ms |
7580 KB |
Output is correct |
31 |
Correct |
60 ms |
7616 KB |
Output is correct |
32 |
Correct |
81 ms |
7636 KB |
Output is correct |
33 |
Correct |
88 ms |
7704 KB |
Output is correct |
34 |
Correct |
81 ms |
7680 KB |
Output is correct |
35 |
Correct |
81 ms |
7624 KB |
Output is correct |
36 |
Correct |
96 ms |
7676 KB |
Output is correct |
37 |
Correct |
59 ms |
5640 KB |
Output is correct |
38 |
Correct |
62 ms |
5580 KB |
Output is correct |
39 |
Correct |
60 ms |
5636 KB |
Output is correct |
40 |
Correct |
68 ms |
5636 KB |
Output is correct |
41 |
Correct |
58 ms |
5568 KB |
Output is correct |
42 |
Correct |
59 ms |
5568 KB |
Output is correct |
43 |
Correct |
174 ms |
14804 KB |
Output is correct |
44 |
Correct |
186 ms |
14896 KB |
Output is correct |
45 |
Correct |
198 ms |
14844 KB |
Output is correct |
46 |
Correct |
178 ms |
14900 KB |
Output is correct |
47 |
Correct |
181 ms |
14912 KB |
Output is correct |
48 |
Correct |
169 ms |
14996 KB |
Output is correct |
49 |
Correct |
161 ms |
14892 KB |
Output is correct |
50 |
Correct |
157 ms |
14892 KB |
Output is correct |
51 |
Correct |
154 ms |
14816 KB |
Output is correct |
52 |
Correct |
162 ms |
14872 KB |
Output is correct |
53 |
Correct |
0 ms |
332 KB |
Output is correct |
54 |
Correct |
1 ms |
332 KB |
Output is correct |
55 |
Correct |
1 ms |
332 KB |
Output is correct |
56 |
Correct |
1 ms |
332 KB |
Output is correct |
57 |
Correct |
1 ms |
332 KB |
Output is correct |
58 |
Correct |
1 ms |
332 KB |
Output is correct |
59 |
Correct |
60 ms |
7684 KB |
Output is correct |
60 |
Correct |
60 ms |
5544 KB |
Output is correct |
61 |
Correct |
60 ms |
5632 KB |
Output is correct |
62 |
Correct |
71 ms |
5572 KB |
Output is correct |
63 |
Correct |
68 ms |
5692 KB |
Output is correct |
64 |
Correct |
66 ms |
5568 KB |
Output is correct |
65 |
Correct |
71 ms |
5640 KB |
Output is correct |
66 |
Correct |
71 ms |
5544 KB |
Output is correct |
67 |
Correct |
71 ms |
5568 KB |
Output is correct |
68 |
Correct |
88 ms |
7640 KB |
Output is correct |
69 |
Correct |
82 ms |
7600 KB |
Output is correct |
70 |
Correct |
79 ms |
7612 KB |
Output is correct |
71 |
Correct |
79 ms |
7580 KB |
Output is correct |
72 |
Correct |
79 ms |
7584 KB |
Output is correct |
73 |
Correct |
71 ms |
5616 KB |
Output is correct |
74 |
Correct |
72 ms |
7612 KB |
Output is correct |
75 |
Correct |
65 ms |
7768 KB |
Output is correct |
76 |
Correct |
59 ms |
5540 KB |
Output is correct |
77 |
Correct |
164 ms |
14876 KB |
Output is correct |
78 |
Correct |
167 ms |
14896 KB |
Output is correct |
79 |
Correct |
171 ms |
15008 KB |
Output is correct |
80 |
Correct |
163 ms |
14812 KB |
Output is correct |
81 |
Correct |
162 ms |
14896 KB |
Output is correct |
82 |
Correct |
166 ms |
14920 KB |
Output is correct |
83 |
Correct |
178 ms |
14900 KB |
Output is correct |
84 |
Correct |
158 ms |
14960 KB |
Output is correct |
85 |
Correct |
157 ms |
14804 KB |
Output is correct |
86 |
Correct |
159 ms |
14840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
2 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
62 ms |
7632 KB |
Output is correct |
24 |
Correct |
69 ms |
7620 KB |
Output is correct |
25 |
Correct |
61 ms |
7632 KB |
Output is correct |
26 |
Correct |
60 ms |
7596 KB |
Output is correct |
27 |
Correct |
56 ms |
5572 KB |
Output is correct |
28 |
Correct |
78 ms |
7612 KB |
Output is correct |
29 |
Correct |
65 ms |
7692 KB |
Output is correct |
30 |
Correct |
62 ms |
7580 KB |
Output is correct |
31 |
Correct |
60 ms |
7616 KB |
Output is correct |
32 |
Correct |
81 ms |
7636 KB |
Output is correct |
33 |
Correct |
88 ms |
7704 KB |
Output is correct |
34 |
Correct |
81 ms |
7680 KB |
Output is correct |
35 |
Correct |
81 ms |
7624 KB |
Output is correct |
36 |
Correct |
96 ms |
7676 KB |
Output is correct |
37 |
Correct |
59 ms |
5640 KB |
Output is correct |
38 |
Correct |
62 ms |
5580 KB |
Output is correct |
39 |
Correct |
60 ms |
5636 KB |
Output is correct |
40 |
Correct |
68 ms |
5636 KB |
Output is correct |
41 |
Correct |
58 ms |
5568 KB |
Output is correct |
42 |
Correct |
59 ms |
5568 KB |
Output is correct |
43 |
Correct |
174 ms |
14804 KB |
Output is correct |
44 |
Correct |
186 ms |
14896 KB |
Output is correct |
45 |
Correct |
198 ms |
14844 KB |
Output is correct |
46 |
Correct |
178 ms |
14900 KB |
Output is correct |
47 |
Correct |
181 ms |
14912 KB |
Output is correct |
48 |
Correct |
169 ms |
14996 KB |
Output is correct |
49 |
Correct |
161 ms |
14892 KB |
Output is correct |
50 |
Correct |
157 ms |
14892 KB |
Output is correct |
51 |
Correct |
154 ms |
14816 KB |
Output is correct |
52 |
Correct |
162 ms |
14872 KB |
Output is correct |
53 |
Correct |
60 ms |
7684 KB |
Output is correct |
54 |
Correct |
60 ms |
5544 KB |
Output is correct |
55 |
Correct |
60 ms |
5632 KB |
Output is correct |
56 |
Correct |
71 ms |
5572 KB |
Output is correct |
57 |
Correct |
68 ms |
5692 KB |
Output is correct |
58 |
Correct |
66 ms |
5568 KB |
Output is correct |
59 |
Correct |
71 ms |
5640 KB |
Output is correct |
60 |
Correct |
71 ms |
5544 KB |
Output is correct |
61 |
Correct |
71 ms |
5568 KB |
Output is correct |
62 |
Correct |
88 ms |
7640 KB |
Output is correct |
63 |
Correct |
82 ms |
7600 KB |
Output is correct |
64 |
Correct |
79 ms |
7612 KB |
Output is correct |
65 |
Correct |
79 ms |
7580 KB |
Output is correct |
66 |
Correct |
79 ms |
7584 KB |
Output is correct |
67 |
Correct |
71 ms |
5616 KB |
Output is correct |
68 |
Correct |
72 ms |
7612 KB |
Output is correct |
69 |
Correct |
65 ms |
7768 KB |
Output is correct |
70 |
Correct |
59 ms |
5540 KB |
Output is correct |
71 |
Correct |
164 ms |
14876 KB |
Output is correct |
72 |
Correct |
167 ms |
14896 KB |
Output is correct |
73 |
Correct |
171 ms |
15008 KB |
Output is correct |
74 |
Correct |
163 ms |
14812 KB |
Output is correct |
75 |
Correct |
162 ms |
14896 KB |
Output is correct |
76 |
Correct |
166 ms |
14920 KB |
Output is correct |
77 |
Correct |
178 ms |
14900 KB |
Output is correct |
78 |
Correct |
158 ms |
14960 KB |
Output is correct |
79 |
Correct |
157 ms |
14804 KB |
Output is correct |
80 |
Correct |
159 ms |
14840 KB |
Output is correct |
81 |
Correct |
0 ms |
332 KB |
Output is correct |
82 |
Correct |
1 ms |
332 KB |
Output is correct |
83 |
Correct |
1 ms |
332 KB |
Output is correct |
84 |
Correct |
1 ms |
332 KB |
Output is correct |
85 |
Correct |
1 ms |
332 KB |
Output is correct |
86 |
Correct |
1 ms |
332 KB |
Output is correct |
87 |
Correct |
84 ms |
5556 KB |
Output is correct |
88 |
Correct |
79 ms |
5676 KB |
Output is correct |
89 |
Correct |
75 ms |
5564 KB |
Output is correct |
90 |
Correct |
73 ms |
5580 KB |
Output is correct |
91 |
Correct |
74 ms |
5588 KB |
Output is correct |
92 |
Correct |
79 ms |
5544 KB |
Output is correct |
93 |
Correct |
79 ms |
5572 KB |
Output is correct |
94 |
Correct |
81 ms |
9248 KB |
Output is correct |
95 |
Correct |
93 ms |
9212 KB |
Output is correct |
96 |
Correct |
79 ms |
9184 KB |
Output is correct |
97 |
Correct |
58 ms |
9992 KB |
Output is correct |
98 |
Correct |
59 ms |
10000 KB |
Output is correct |
99 |
Correct |
60 ms |
10048 KB |
Output is correct |
100 |
Correct |
71 ms |
10164 KB |
Output is correct |
101 |
Correct |
60 ms |
9952 KB |
Output is correct |
102 |
Correct |
63 ms |
9956 KB |
Output is correct |
103 |
Correct |
66 ms |
10020 KB |
Output is correct |
104 |
Correct |
64 ms |
9996 KB |
Output is correct |
105 |
Correct |
64 ms |
10004 KB |
Output is correct |
106 |
Correct |
64 ms |
9952 KB |
Output is correct |