Submission #913935

# Submission time Handle Problem Language Result Execution time Memory
913935 2024-01-20T14:59:16 Z vjudge1 Wish (LMIO19_noras) C++17
100 / 100
141 ms 29296 KB
#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 = 2e9; l <= r;){
				ll mid = (l + r) >> 1;
				__int128 x = a[i] + c[i] * mid;
				__int128 y = b[i] + d[i] * mid;
				if(ok(x, y)){
					s = mid; r = mid - 1;
				} else{
					__int128 x1 = a[i] + c[i] * (mid + 1);
					__int128 y1 = b[i] + d[i] * (mid + 1);
					if(x * x + y * y < x1 * x1 + y1 * y1) r = mid - 1;
					else l = mid + 1;
				}
			}
		}
		if(s != -1){
			ll t = -1;
			for(ll l = s, r = 2e9; 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:70: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]
   70 |  for(int i = 0; i < v.size();){
      |                 ~~^~~~~~~~~~
noras.cpp:72: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]
   72 |   while(j < v.size() && v[j].first == v[i].first){
      |         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6616 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 3 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6616 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 3 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 50 ms 22512 KB Output is correct
24 Correct 53 ms 21708 KB Output is correct
25 Correct 50 ms 22480 KB Output is correct
26 Correct 51 ms 20828 KB Output is correct
27 Correct 47 ms 18892 KB Output is correct
28 Correct 52 ms 22220 KB Output is correct
29 Correct 54 ms 21852 KB Output is correct
30 Correct 52 ms 23016 KB Output is correct
31 Correct 52 ms 20940 KB Output is correct
32 Correct 67 ms 22396 KB Output is correct
33 Correct 65 ms 22732 KB Output is correct
34 Correct 65 ms 21964 KB Output is correct
35 Correct 65 ms 21452 KB Output is correct
36 Correct 65 ms 22480 KB Output is correct
37 Correct 51 ms 18644 KB Output is correct
38 Correct 53 ms 18640 KB Output is correct
39 Correct 44 ms 18640 KB Output is correct
40 Correct 47 ms 18636 KB Output is correct
41 Correct 46 ms 18648 KB Output is correct
42 Correct 46 ms 18892 KB Output is correct
43 Correct 138 ms 27752 KB Output is correct
44 Correct 137 ms 28640 KB Output is correct
45 Correct 136 ms 27836 KB Output is correct
46 Correct 137 ms 28404 KB Output is correct
47 Correct 137 ms 28132 KB Output is correct
48 Correct 127 ms 28612 KB Output is correct
49 Correct 126 ms 27072 KB Output is correct
50 Correct 130 ms 26980 KB Output is correct
51 Correct 127 ms 27120 KB Output is correct
52 Correct 128 ms 26820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6616 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 3 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 1 ms 6492 KB Output is correct
24 Correct 2 ms 6492 KB Output is correct
25 Correct 2 ms 6488 KB Output is correct
26 Correct 2 ms 6492 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6616 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 3 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 50 ms 22512 KB Output is correct
24 Correct 53 ms 21708 KB Output is correct
25 Correct 50 ms 22480 KB Output is correct
26 Correct 51 ms 20828 KB Output is correct
27 Correct 47 ms 18892 KB Output is correct
28 Correct 52 ms 22220 KB Output is correct
29 Correct 54 ms 21852 KB Output is correct
30 Correct 52 ms 23016 KB Output is correct
31 Correct 52 ms 20940 KB Output is correct
32 Correct 67 ms 22396 KB Output is correct
33 Correct 65 ms 22732 KB Output is correct
34 Correct 65 ms 21964 KB Output is correct
35 Correct 65 ms 21452 KB Output is correct
36 Correct 65 ms 22480 KB Output is correct
37 Correct 51 ms 18644 KB Output is correct
38 Correct 53 ms 18640 KB Output is correct
39 Correct 44 ms 18640 KB Output is correct
40 Correct 47 ms 18636 KB Output is correct
41 Correct 46 ms 18648 KB Output is correct
42 Correct 46 ms 18892 KB Output is correct
43 Correct 138 ms 27752 KB Output is correct
44 Correct 137 ms 28640 KB Output is correct
45 Correct 136 ms 27836 KB Output is correct
46 Correct 137 ms 28404 KB Output is correct
47 Correct 137 ms 28132 KB Output is correct
48 Correct 127 ms 28612 KB Output is correct
49 Correct 126 ms 27072 KB Output is correct
50 Correct 130 ms 26980 KB Output is correct
51 Correct 127 ms 27120 KB Output is correct
52 Correct 128 ms 26820 KB Output is correct
53 Correct 1 ms 6492 KB Output is correct
54 Correct 2 ms 6492 KB Output is correct
55 Correct 2 ms 6488 KB Output is correct
56 Correct 2 ms 6492 KB Output is correct
57 Correct 2 ms 6492 KB Output is correct
58 Correct 2 ms 6492 KB Output is correct
59 Correct 60 ms 22220 KB Output is correct
60 Correct 49 ms 19148 KB Output is correct
61 Correct 48 ms 19068 KB Output is correct
62 Correct 50 ms 19152 KB Output is correct
63 Correct 55 ms 19152 KB Output is correct
64 Correct 55 ms 19152 KB Output is correct
65 Correct 55 ms 19036 KB Output is correct
66 Correct 55 ms 19148 KB Output is correct
67 Correct 60 ms 19148 KB Output is correct
68 Correct 69 ms 22624 KB Output is correct
69 Correct 73 ms 22004 KB Output is correct
70 Correct 71 ms 21704 KB Output is correct
71 Correct 69 ms 21880 KB Output is correct
72 Correct 72 ms 22984 KB Output is correct
73 Correct 58 ms 18508 KB Output is correct
74 Correct 49 ms 22024 KB Output is correct
75 Correct 61 ms 20596 KB Output is correct
76 Correct 50 ms 18844 KB Output is correct
77 Correct 134 ms 27700 KB Output is correct
78 Correct 127 ms 28612 KB Output is correct
79 Correct 128 ms 29296 KB Output is correct
80 Correct 125 ms 29020 KB Output is correct
81 Correct 126 ms 28356 KB Output is correct
82 Correct 137 ms 28596 KB Output is correct
83 Correct 136 ms 29108 KB Output is correct
84 Correct 141 ms 27840 KB Output is correct
85 Correct 135 ms 28524 KB Output is correct
86 Correct 139 ms 28720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 2 ms 6492 KB Output is correct
4 Correct 2 ms 6488 KB Output is correct
5 Correct 2 ms 6492 KB Output is correct
6 Correct 2 ms 6492 KB Output is correct
7 Correct 2 ms 6492 KB Output is correct
8 Correct 2 ms 6488 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6616 KB Output is correct
16 Correct 2 ms 6492 KB Output is correct
17 Correct 3 ms 6488 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 2 ms 6492 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 2 ms 6492 KB Output is correct
22 Correct 2 ms 6492 KB Output is correct
23 Correct 50 ms 22512 KB Output is correct
24 Correct 53 ms 21708 KB Output is correct
25 Correct 50 ms 22480 KB Output is correct
26 Correct 51 ms 20828 KB Output is correct
27 Correct 47 ms 18892 KB Output is correct
28 Correct 52 ms 22220 KB Output is correct
29 Correct 54 ms 21852 KB Output is correct
30 Correct 52 ms 23016 KB Output is correct
31 Correct 52 ms 20940 KB Output is correct
32 Correct 67 ms 22396 KB Output is correct
33 Correct 65 ms 22732 KB Output is correct
34 Correct 65 ms 21964 KB Output is correct
35 Correct 65 ms 21452 KB Output is correct
36 Correct 65 ms 22480 KB Output is correct
37 Correct 51 ms 18644 KB Output is correct
38 Correct 53 ms 18640 KB Output is correct
39 Correct 44 ms 18640 KB Output is correct
40 Correct 47 ms 18636 KB Output is correct
41 Correct 46 ms 18648 KB Output is correct
42 Correct 46 ms 18892 KB Output is correct
43 Correct 138 ms 27752 KB Output is correct
44 Correct 137 ms 28640 KB Output is correct
45 Correct 136 ms 27836 KB Output is correct
46 Correct 137 ms 28404 KB Output is correct
47 Correct 137 ms 28132 KB Output is correct
48 Correct 127 ms 28612 KB Output is correct
49 Correct 126 ms 27072 KB Output is correct
50 Correct 130 ms 26980 KB Output is correct
51 Correct 127 ms 27120 KB Output is correct
52 Correct 128 ms 26820 KB Output is correct
53 Correct 60 ms 22220 KB Output is correct
54 Correct 49 ms 19148 KB Output is correct
55 Correct 48 ms 19068 KB Output is correct
56 Correct 50 ms 19152 KB Output is correct
57 Correct 55 ms 19152 KB Output is correct
58 Correct 55 ms 19152 KB Output is correct
59 Correct 55 ms 19036 KB Output is correct
60 Correct 55 ms 19148 KB Output is correct
61 Correct 60 ms 19148 KB Output is correct
62 Correct 69 ms 22624 KB Output is correct
63 Correct 73 ms 22004 KB Output is correct
64 Correct 71 ms 21704 KB Output is correct
65 Correct 69 ms 21880 KB Output is correct
66 Correct 72 ms 22984 KB Output is correct
67 Correct 58 ms 18508 KB Output is correct
68 Correct 49 ms 22024 KB Output is correct
69 Correct 61 ms 20596 KB Output is correct
70 Correct 50 ms 18844 KB Output is correct
71 Correct 134 ms 27700 KB Output is correct
72 Correct 127 ms 28612 KB Output is correct
73 Correct 128 ms 29296 KB Output is correct
74 Correct 125 ms 29020 KB Output is correct
75 Correct 126 ms 28356 KB Output is correct
76 Correct 137 ms 28596 KB Output is correct
77 Correct 136 ms 29108 KB Output is correct
78 Correct 141 ms 27840 KB Output is correct
79 Correct 135 ms 28524 KB Output is correct
80 Correct 139 ms 28720 KB Output is correct
81 Correct 1 ms 6492 KB Output is correct
82 Correct 2 ms 6492 KB Output is correct
83 Correct 2 ms 6488 KB Output is correct
84 Correct 2 ms 6492 KB Output is correct
85 Correct 2 ms 6492 KB Output is correct
86 Correct 2 ms 6492 KB Output is correct
87 Correct 66 ms 20684 KB Output is correct
88 Correct 64 ms 20740 KB Output is correct
89 Correct 64 ms 20696 KB Output is correct
90 Correct 65 ms 20684 KB Output is correct
91 Correct 64 ms 20596 KB Output is correct
92 Correct 72 ms 20720 KB Output is correct
93 Correct 67 ms 20588 KB Output is correct
94 Correct 66 ms 20688 KB Output is correct
95 Correct 67 ms 20688 KB Output is correct
96 Correct 66 ms 20688 KB Output is correct
97 Correct 59 ms 22248 KB Output is correct
98 Correct 58 ms 22552 KB Output is correct
99 Correct 56 ms 21964 KB Output is correct
100 Correct 66 ms 23496 KB Output is correct
101 Correct 56 ms 23240 KB Output is correct
102 Correct 55 ms 21448 KB Output is correct
103 Correct 56 ms 23136 KB Output is correct
104 Correct 57 ms 22472 KB Output is correct
105 Correct 56 ms 23248 KB Output is correct
106 Correct 55 ms 22380 KB Output is correct