Submission #639085

# Submission time Handle Problem Language Result Execution time Memory
639085 2022-09-08T14:22:44 Z luanaamorim Wish (LMIO19_noras) C++14
100 / 100
124 ms 11416 KB
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring>
#include <set>
#include <stack>
#include <bitset>
#define dbug(x) cout << (#x) << " -> " << x << endl
#define ll long long
#define INF (1e9)
#define MAX (int) (2e5 + 5)
#define MOD 1000000007
#define par pair<int, int>
#define all(v) v.begin(), v.end()
#define sz(x) (int) ((x).size())
#define esq(x) (x<<1)
#define dir(x) ((x<<1)|1)
#define lsb(x) (x & -x)
#define W(x) cout << #x << ": " << x << endl
#define Wii(x) cout << x.first << ' ' << x.second << endl
#define _ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

ll n, r, a, b, deltax, deltay, resp, qtd;
vector<pair<ll, ll> > v;
priority_queue<ll, vector<ll>, greater<ll> > pq;

pair<ll, ll> tempo(double x, double y, double dx, double dy)
{
	int ok = 0;
	double a = (dx*dx) + (dy*dy);
	double b = (2*dx*x) + (2*dy*y);
	double c = (x*x) + (y*y) - (r*r);
	// dbug(a);
	// dbug(b);
	// dbug(c);
	double delta = (b*b) - (4*a*c);
	// dbug(delta);
	if (delta<0) return {INF, INF};
	double r1 = (-b - sqrt(delta)) / (2*a);
	double r2 = (-b + sqrt(delta)) / (2*a);
	// dbug(delta);
	// dbug(r1);
	// dbug(r2);

	// dbug(sqrt(delta));
	for (ll i = max((double)0, r1-2); i <= r1+2; i++)
	{
		ll px = x + (dx*i);
		ll py = y + (dy*i);
		// dbug(px);
		// dbug(py);
		if ((px*px) + (py*py) <= r*r) 
		{
			// dbug(r1);
			ok = 1;
			r1 = i;
			break;
		}
	}

	for (ll i = r2+2; i >= max((double)0, r2-2); i--)
	{
		ll px = x + (dx*i);
		ll py = y + (dy*i);
		if ((px*px) + (py*py) <= r*r) 
		{
			ok = 1;
			r2 = i;
			break;
		}
	}

	if (!ok) return {INF, INF};
	return {max(0LL, (ll)r1), (ll)r2};
}

int main()
{_
	cin >> n >> r;
	for (int i = 1; i <= n; i++)
	{
		cin >> a >> b >> deltax >> deltay;
		deltax -= a;
		deltay -= b;
		// dbug(deltax);
		// dbug(deltay);
		v.push_back(tempo(a, b, deltax, deltay));
	}

	sort(all(v));
	for (auto[l, r] : v)
	{
		if (l == INF && r == INF) break;
		// cout << l << ' ' << r << endl;
		while (!pq.empty() && pq.top() < l) pq.pop(), qtd--;
		qtd++;
		resp = max(resp, qtd);
		pq.push(r);
	}

	cout << resp << endl;

}














Compilation message

noras.cpp: In function 'int main()':
noras.cpp:98:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   98 |  for (auto[l, r] : v)
      |           ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 38 ms 5136 KB Output is correct
24 Correct 40 ms 5128 KB Output is correct
25 Correct 38 ms 5160 KB Output is correct
26 Correct 37 ms 5140 KB Output is correct
27 Correct 36 ms 4536 KB Output is correct
28 Correct 35 ms 4452 KB Output is correct
29 Correct 51 ms 4428 KB Output is correct
30 Correct 37 ms 4544 KB Output is correct
31 Correct 37 ms 4480 KB Output is correct
32 Correct 51 ms 4088 KB Output is correct
33 Correct 51 ms 3984 KB Output is correct
34 Correct 47 ms 4036 KB Output is correct
35 Correct 59 ms 3988 KB Output is correct
36 Correct 51 ms 4080 KB Output is correct
37 Correct 41 ms 4168 KB Output is correct
38 Correct 39 ms 4268 KB Output is correct
39 Correct 39 ms 4236 KB Output is correct
40 Correct 39 ms 4268 KB Output is correct
41 Correct 36 ms 4132 KB Output is correct
42 Correct 36 ms 4300 KB Output is correct
43 Correct 116 ms 11260 KB Output is correct
44 Correct 93 ms 11308 KB Output is correct
45 Correct 97 ms 11256 KB Output is correct
46 Correct 95 ms 11416 KB Output is correct
47 Correct 89 ms 11236 KB Output is correct
48 Correct 104 ms 7920 KB Output is correct
49 Correct 122 ms 7916 KB Output is correct
50 Correct 102 ms 7856 KB Output is correct
51 Correct 101 ms 7812 KB Output is correct
52 Correct 117 ms 7632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 328 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 332 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 38 ms 5136 KB Output is correct
24 Correct 40 ms 5128 KB Output is correct
25 Correct 38 ms 5160 KB Output is correct
26 Correct 37 ms 5140 KB Output is correct
27 Correct 36 ms 4536 KB Output is correct
28 Correct 35 ms 4452 KB Output is correct
29 Correct 51 ms 4428 KB Output is correct
30 Correct 37 ms 4544 KB Output is correct
31 Correct 37 ms 4480 KB Output is correct
32 Correct 51 ms 4088 KB Output is correct
33 Correct 51 ms 3984 KB Output is correct
34 Correct 47 ms 4036 KB Output is correct
35 Correct 59 ms 3988 KB Output is correct
36 Correct 51 ms 4080 KB Output is correct
37 Correct 41 ms 4168 KB Output is correct
38 Correct 39 ms 4268 KB Output is correct
39 Correct 39 ms 4236 KB Output is correct
40 Correct 39 ms 4268 KB Output is correct
41 Correct 36 ms 4132 KB Output is correct
42 Correct 36 ms 4300 KB Output is correct
43 Correct 116 ms 11260 KB Output is correct
44 Correct 93 ms 11308 KB Output is correct
45 Correct 97 ms 11256 KB Output is correct
46 Correct 95 ms 11416 KB Output is correct
47 Correct 89 ms 11236 KB Output is correct
48 Correct 104 ms 7920 KB Output is correct
49 Correct 122 ms 7916 KB Output is correct
50 Correct 102 ms 7856 KB Output is correct
51 Correct 101 ms 7812 KB Output is correct
52 Correct 117 ms 7632 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 328 KB Output is correct
55 Correct 1 ms 340 KB Output is correct
56 Correct 2 ms 332 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 2 ms 344 KB Output is correct
59 Correct 40 ms 5144 KB Output is correct
60 Correct 44 ms 4112 KB Output is correct
61 Correct 57 ms 4260 KB Output is correct
62 Correct 44 ms 4260 KB Output is correct
63 Correct 54 ms 4068 KB Output is correct
64 Correct 46 ms 4032 KB Output is correct
65 Correct 47 ms 4152 KB Output is correct
66 Correct 50 ms 4084 KB Output is correct
67 Correct 44 ms 4032 KB Output is correct
68 Correct 54 ms 4164 KB Output is correct
69 Correct 52 ms 3876 KB Output is correct
70 Correct 52 ms 3960 KB Output is correct
71 Correct 52 ms 3872 KB Output is correct
72 Correct 51 ms 4040 KB Output is correct
73 Correct 45 ms 4180 KB Output is correct
74 Correct 40 ms 4364 KB Output is correct
75 Correct 41 ms 4332 KB Output is correct
76 Correct 47 ms 4380 KB Output is correct
77 Correct 92 ms 10952 KB Output is correct
78 Correct 92 ms 10896 KB Output is correct
79 Correct 98 ms 10900 KB Output is correct
80 Correct 90 ms 10880 KB Output is correct
81 Correct 93 ms 10876 KB Output is correct
82 Correct 109 ms 7972 KB Output is correct
83 Correct 124 ms 8104 KB Output is correct
84 Correct 107 ms 7972 KB Output is correct
85 Correct 120 ms 7584 KB Output is correct
86 Correct 106 ms 7988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 324 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 320 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 38 ms 5136 KB Output is correct
24 Correct 40 ms 5128 KB Output is correct
25 Correct 38 ms 5160 KB Output is correct
26 Correct 37 ms 5140 KB Output is correct
27 Correct 36 ms 4536 KB Output is correct
28 Correct 35 ms 4452 KB Output is correct
29 Correct 51 ms 4428 KB Output is correct
30 Correct 37 ms 4544 KB Output is correct
31 Correct 37 ms 4480 KB Output is correct
32 Correct 51 ms 4088 KB Output is correct
33 Correct 51 ms 3984 KB Output is correct
34 Correct 47 ms 4036 KB Output is correct
35 Correct 59 ms 3988 KB Output is correct
36 Correct 51 ms 4080 KB Output is correct
37 Correct 41 ms 4168 KB Output is correct
38 Correct 39 ms 4268 KB Output is correct
39 Correct 39 ms 4236 KB Output is correct
40 Correct 39 ms 4268 KB Output is correct
41 Correct 36 ms 4132 KB Output is correct
42 Correct 36 ms 4300 KB Output is correct
43 Correct 116 ms 11260 KB Output is correct
44 Correct 93 ms 11308 KB Output is correct
45 Correct 97 ms 11256 KB Output is correct
46 Correct 95 ms 11416 KB Output is correct
47 Correct 89 ms 11236 KB Output is correct
48 Correct 104 ms 7920 KB Output is correct
49 Correct 122 ms 7916 KB Output is correct
50 Correct 102 ms 7856 KB Output is correct
51 Correct 101 ms 7812 KB Output is correct
52 Correct 117 ms 7632 KB Output is correct
53 Correct 40 ms 5144 KB Output is correct
54 Correct 44 ms 4112 KB Output is correct
55 Correct 57 ms 4260 KB Output is correct
56 Correct 44 ms 4260 KB Output is correct
57 Correct 54 ms 4068 KB Output is correct
58 Correct 46 ms 4032 KB Output is correct
59 Correct 47 ms 4152 KB Output is correct
60 Correct 50 ms 4084 KB Output is correct
61 Correct 44 ms 4032 KB Output is correct
62 Correct 54 ms 4164 KB Output is correct
63 Correct 52 ms 3876 KB Output is correct
64 Correct 52 ms 3960 KB Output is correct
65 Correct 52 ms 3872 KB Output is correct
66 Correct 51 ms 4040 KB Output is correct
67 Correct 45 ms 4180 KB Output is correct
68 Correct 40 ms 4364 KB Output is correct
69 Correct 41 ms 4332 KB Output is correct
70 Correct 47 ms 4380 KB Output is correct
71 Correct 92 ms 10952 KB Output is correct
72 Correct 92 ms 10896 KB Output is correct
73 Correct 98 ms 10900 KB Output is correct
74 Correct 90 ms 10880 KB Output is correct
75 Correct 93 ms 10876 KB Output is correct
76 Correct 109 ms 7972 KB Output is correct
77 Correct 124 ms 8104 KB Output is correct
78 Correct 107 ms 7972 KB Output is correct
79 Correct 120 ms 7584 KB Output is correct
80 Correct 106 ms 7988 KB Output is correct
81 Correct 1 ms 212 KB Output is correct
82 Correct 1 ms 328 KB Output is correct
83 Correct 1 ms 340 KB Output is correct
84 Correct 2 ms 332 KB Output is correct
85 Correct 1 ms 340 KB Output is correct
86 Correct 2 ms 344 KB Output is correct
87 Correct 52 ms 5604 KB Output is correct
88 Correct 59 ms 5800 KB Output is correct
89 Correct 60 ms 5712 KB Output is correct
90 Correct 61 ms 5648 KB Output is correct
91 Correct 55 ms 5700 KB Output is correct
92 Correct 59 ms 5668 KB Output is correct
93 Correct 56 ms 5612 KB Output is correct
94 Correct 54 ms 5832 KB Output is correct
95 Correct 53 ms 5608 KB Output is correct
96 Correct 56 ms 5624 KB Output is correct
97 Correct 48 ms 6040 KB Output is correct
98 Correct 42 ms 5932 KB Output is correct
99 Correct 40 ms 5952 KB Output is correct
100 Correct 42 ms 5972 KB Output is correct
101 Correct 40 ms 5960 KB Output is correct
102 Correct 40 ms 5924 KB Output is correct
103 Correct 44 ms 5996 KB Output is correct
104 Correct 43 ms 5964 KB Output is correct
105 Correct 43 ms 5960 KB Output is correct
106 Correct 43 ms 5892 KB Output is correct