답안 #1016075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1016075 2024-07-07T11:19:18 Z vjudge1 Wish (LMIO19_noras) C++17
100 / 100
99 ms 8660 KB
#include <bits/stdc++.h>
using namespace std;
#define big __int128_t
// #define big long long

const long double eps = 1e-12;
const long long inf = 1LL << 60;
const long long lim = 1e9;

long long R, sx, sy, sx2, sy2, vx, vy, l, r; big X, Y, Z, T;

bool check(long long a) { // is it in the circle
	if (a < 0) return 0;
	if (a > lim) return 0;
	return (sx + a * vx) * (sx + a * vx) + (sy + a * vy) * (sy + a * vy) <= R * R;
}

pair<long long, long long> p[200008];
vector<long long> tbc;

void compress() {sort(tbc.begin(), tbc.end()); tbc.resize(unique(tbc.begin(), tbc.end()) - tbc.begin());}
int order(long long key) {return lower_bound(tbc.begin(), tbc.end(), key) - tbc.begin() + 1;}

int upd[400008];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, ans = 0, m = 0; cin >> n >> R;
	pair<long long, long long> range;
	for (int i = 1; i <= n; ++i) {
		cin >> sx >> sy >> sx2 >> sy2; vx = sx2 - sx; vy = sy2 - sy;
		X = vx * vx + vy * vy; Y = 2 * (sx * vx + sy * vy);
		Z = R * R - sx * sx - sy * sy; T = 4 * X * Z + Y * Y;
		if (T < 0) continue;
		l = (-Y - sqrtl(T)) / (2 * X); r = (-Y + sqrtl(T)) / (2 * X);
		l = max(l, 0LL); r = max(r, 0LL);
		range = {1, -1};
		for (long long i = l - 10; i <= l + 10; ++i) if (check(i)) {range.first = i; break;}
		for (long long i = r + 10; i >= r - 10; --i) if (check(i)) {range.second = i; break;}
		if (range.first <= range.second) {
			p[++m] = range;
			tbc.push_back(range.first); tbc.push_back(range.second);
		}
	}
	compress();
	for (int i = 1; i <= m; ++i) p[i].first = order(p[i].first), p[i].second = order(p[i].second);
	for (int i = 1; i <= m; ++i) ++upd[p[i].first], --upd[p[i].second + 1];
	for (int i = 1; i <= tbc.size() + 1; ++i) upd[i] += upd[i - 1];
	ans += *max_element(upd + 1, upd + tbc.size() + 1);
	cout << ans;
}

Compilation message

noras.cpp: In function 'int main()':
noras.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for (int i = 1; i <= tbc.size() + 1; ++i) upd[i] += upd[i - 1];
      |                  ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 32 ms 3544 KB Output is correct
24 Correct 28 ms 5080 KB Output is correct
25 Correct 31 ms 3668 KB Output is correct
26 Correct 30 ms 3452 KB Output is correct
27 Correct 27 ms 2088 KB Output is correct
28 Correct 29 ms 4888 KB Output is correct
29 Correct 29 ms 5080 KB Output is correct
30 Correct 31 ms 3536 KB Output is correct
31 Correct 30 ms 3544 KB Output is correct
32 Correct 42 ms 3544 KB Output is correct
33 Correct 47 ms 3532 KB Output is correct
34 Correct 40 ms 5076 KB Output is correct
35 Correct 35 ms 4864 KB Output is correct
36 Correct 36 ms 3612 KB Output is correct
37 Correct 25 ms 2508 KB Output is correct
38 Correct 33 ms 2512 KB Output is correct
39 Correct 24 ms 2012 KB Output is correct
40 Correct 27 ms 2264 KB Output is correct
41 Correct 26 ms 2012 KB Output is correct
42 Correct 26 ms 2000 KB Output is correct
43 Correct 92 ms 6856 KB Output is correct
44 Correct 91 ms 8280 KB Output is correct
45 Correct 89 ms 8660 KB Output is correct
46 Correct 99 ms 8144 KB Output is correct
47 Correct 86 ms 8132 KB Output is correct
48 Correct 82 ms 7968 KB Output is correct
49 Correct 74 ms 8136 KB Output is correct
50 Correct 72 ms 8132 KB Output is correct
51 Correct 73 ms 8136 KB Output is correct
52 Correct 75 ms 6612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 600 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 32 ms 3544 KB Output is correct
24 Correct 28 ms 5080 KB Output is correct
25 Correct 31 ms 3668 KB Output is correct
26 Correct 30 ms 3452 KB Output is correct
27 Correct 27 ms 2088 KB Output is correct
28 Correct 29 ms 4888 KB Output is correct
29 Correct 29 ms 5080 KB Output is correct
30 Correct 31 ms 3536 KB Output is correct
31 Correct 30 ms 3544 KB Output is correct
32 Correct 42 ms 3544 KB Output is correct
33 Correct 47 ms 3532 KB Output is correct
34 Correct 40 ms 5076 KB Output is correct
35 Correct 35 ms 4864 KB Output is correct
36 Correct 36 ms 3612 KB Output is correct
37 Correct 25 ms 2508 KB Output is correct
38 Correct 33 ms 2512 KB Output is correct
39 Correct 24 ms 2012 KB Output is correct
40 Correct 27 ms 2264 KB Output is correct
41 Correct 26 ms 2012 KB Output is correct
42 Correct 26 ms 2000 KB Output is correct
43 Correct 92 ms 6856 KB Output is correct
44 Correct 91 ms 8280 KB Output is correct
45 Correct 89 ms 8660 KB Output is correct
46 Correct 99 ms 8144 KB Output is correct
47 Correct 86 ms 8132 KB Output is correct
48 Correct 82 ms 7968 KB Output is correct
49 Correct 74 ms 8136 KB Output is correct
50 Correct 72 ms 8132 KB Output is correct
51 Correct 73 ms 8136 KB Output is correct
52 Correct 75 ms 6612 KB Output is correct
53 Correct 1 ms 600 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 0 ms 348 KB Output is correct
57 Correct 1 ms 2396 KB Output is correct
58 Correct 1 ms 348 KB Output is correct
59 Correct 30 ms 3608 KB Output is correct
60 Correct 25 ms 3548 KB Output is correct
61 Correct 25 ms 3988 KB Output is correct
62 Correct 26 ms 3664 KB Output is correct
63 Correct 37 ms 3668 KB Output is correct
64 Correct 31 ms 1948 KB Output is correct
65 Correct 33 ms 2012 KB Output is correct
66 Correct 37 ms 3412 KB Output is correct
67 Correct 34 ms 2168 KB Output is correct
68 Correct 39 ms 5080 KB Output is correct
69 Correct 40 ms 5076 KB Output is correct
70 Correct 42 ms 5080 KB Output is correct
71 Correct 38 ms 3544 KB Output is correct
72 Correct 41 ms 3664 KB Output is correct
73 Correct 29 ms 2264 KB Output is correct
74 Correct 29 ms 3544 KB Output is correct
75 Correct 33 ms 3544 KB Output is correct
76 Correct 29 ms 2252 KB Output is correct
77 Correct 90 ms 6648 KB Output is correct
78 Correct 81 ms 6596 KB Output is correct
79 Correct 81 ms 6604 KB Output is correct
80 Correct 92 ms 6600 KB Output is correct
81 Correct 81 ms 8140 KB Output is correct
82 Correct 91 ms 8084 KB Output is correct
83 Correct 80 ms 8148 KB Output is correct
84 Correct 80 ms 6616 KB Output is correct
85 Correct 92 ms 6600 KB Output is correct
86 Correct 79 ms 8132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 32 ms 3544 KB Output is correct
24 Correct 28 ms 5080 KB Output is correct
25 Correct 31 ms 3668 KB Output is correct
26 Correct 30 ms 3452 KB Output is correct
27 Correct 27 ms 2088 KB Output is correct
28 Correct 29 ms 4888 KB Output is correct
29 Correct 29 ms 5080 KB Output is correct
30 Correct 31 ms 3536 KB Output is correct
31 Correct 30 ms 3544 KB Output is correct
32 Correct 42 ms 3544 KB Output is correct
33 Correct 47 ms 3532 KB Output is correct
34 Correct 40 ms 5076 KB Output is correct
35 Correct 35 ms 4864 KB Output is correct
36 Correct 36 ms 3612 KB Output is correct
37 Correct 25 ms 2508 KB Output is correct
38 Correct 33 ms 2512 KB Output is correct
39 Correct 24 ms 2012 KB Output is correct
40 Correct 27 ms 2264 KB Output is correct
41 Correct 26 ms 2012 KB Output is correct
42 Correct 26 ms 2000 KB Output is correct
43 Correct 92 ms 6856 KB Output is correct
44 Correct 91 ms 8280 KB Output is correct
45 Correct 89 ms 8660 KB Output is correct
46 Correct 99 ms 8144 KB Output is correct
47 Correct 86 ms 8132 KB Output is correct
48 Correct 82 ms 7968 KB Output is correct
49 Correct 74 ms 8136 KB Output is correct
50 Correct 72 ms 8132 KB Output is correct
51 Correct 73 ms 8136 KB Output is correct
52 Correct 75 ms 6612 KB Output is correct
53 Correct 30 ms 3608 KB Output is correct
54 Correct 25 ms 3548 KB Output is correct
55 Correct 25 ms 3988 KB Output is correct
56 Correct 26 ms 3664 KB Output is correct
57 Correct 37 ms 3668 KB Output is correct
58 Correct 31 ms 1948 KB Output is correct
59 Correct 33 ms 2012 KB Output is correct
60 Correct 37 ms 3412 KB Output is correct
61 Correct 34 ms 2168 KB Output is correct
62 Correct 39 ms 5080 KB Output is correct
63 Correct 40 ms 5076 KB Output is correct
64 Correct 42 ms 5080 KB Output is correct
65 Correct 38 ms 3544 KB Output is correct
66 Correct 41 ms 3664 KB Output is correct
67 Correct 29 ms 2264 KB Output is correct
68 Correct 29 ms 3544 KB Output is correct
69 Correct 33 ms 3544 KB Output is correct
70 Correct 29 ms 2252 KB Output is correct
71 Correct 90 ms 6648 KB Output is correct
72 Correct 81 ms 6596 KB Output is correct
73 Correct 81 ms 6604 KB Output is correct
74 Correct 92 ms 6600 KB Output is correct
75 Correct 81 ms 8140 KB Output is correct
76 Correct 91 ms 8084 KB Output is correct
77 Correct 80 ms 8148 KB Output is correct
78 Correct 80 ms 6616 KB Output is correct
79 Correct 92 ms 6600 KB Output is correct
80 Correct 79 ms 8132 KB Output is correct
81 Correct 1 ms 600 KB Output is correct
82 Correct 0 ms 348 KB Output is correct
83 Correct 1 ms 348 KB Output is correct
84 Correct 0 ms 348 KB Output is correct
85 Correct 1 ms 2396 KB Output is correct
86 Correct 1 ms 348 KB Output is correct
87 Correct 39 ms 2252 KB Output is correct
88 Correct 42 ms 3548 KB Output is correct
89 Correct 40 ms 3548 KB Output is correct
90 Correct 51 ms 2020 KB Output is correct
91 Correct 37 ms 2108 KB Output is correct
92 Correct 45 ms 2256 KB Output is correct
93 Correct 47 ms 2164 KB Output is correct
94 Correct 46 ms 2252 KB Output is correct
95 Correct 50 ms 2288 KB Output is correct
96 Correct 46 ms 2156 KB Output is correct
97 Correct 31 ms 3544 KB Output is correct
98 Correct 38 ms 3544 KB Output is correct
99 Correct 29 ms 3540 KB Output is correct
100 Correct 29 ms 3540 KB Output is correct
101 Correct 31 ms 3600 KB Output is correct
102 Correct 29 ms 3544 KB Output is correct
103 Correct 29 ms 3552 KB Output is correct
104 Correct 31 ms 3544 KB Output is correct
105 Correct 31 ms 3544 KB Output is correct
106 Correct 29 ms 3644 KB Output is correct