#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
using ll = long long;
ll gcd(ll a, ll b)
{
a = abs(a);
b = abs(b);
if(a < b)
swap(a, b);
if(a == 0)
return 1;
if(b == 0)
return a;
return gcd(b, a % b);
}
double getA(double x, double y, double z)
{
if(!x && !y && !z)
return -1;
double a = (x - y / 2.0 - z / 2.0) / sqrt(x * x + y * y + z * z) / sqrt(1.5);
if(a > 1)
a = 1;
if(a < -1)
a = -1;
a = acos(a);
if(y < z)
a = 2 * PI - a;
return a;
}
struct point
{
ll x, y, z;
bool operator < (const point& p) const
{
return getA(x, y, z) < getA(p.x, p.y, p.z);
}
};
double getA(point p)
{
return getA(p.x, p.y, p.z);
}
point inv(point p)
{
return point{-p.x, -p.y, -p.z};
}
map<point,int> m;
set<point> s;
bool solve()
{
if(s.empty())
return 0;
auto it = s.begin();
if(getA(*it) > PI)
return 0;
it = s.lower_bound(inv(*it));
if(it == s.end())
return 0;
double hi = getA(*it);
it --;
if(it == s.begin())
return 0;
double lo = getA(*it);
return hi - lo <= PI;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
ll X,Y,Z,T;
cin >> X >> Y >> Z;
T = X + Y + Z;
int N;
cin >> N;
int num = 0;
ll cnt = 0;
vector<point> p(N + 1);
vector<double> a(N + 1);
p[0] = point{0, 0, 0};
while(N --)
{
char C;
cin >> C;
ll x, y, z, t, g;
if(C == 'A')
{
cin >> x >> y >> z;
t = x + y + z;
x = x * T - X *t, y = y * T - Y * t, z = z * T -Z * t;
g = gcd(gcd(x,y), z);
x /= g, y /= g, z /= g;
p[++ num] = point{x, y, z};
m[p[num]] ++;
s.insert(p[num]);
if(x || y || z)
cnt += m[inv(p[num])];
}
if(C == 'R')
{
cin >> t;
m[p[t]] --;
if(!m[p[t]])
s.erase(p[t]);
if(p[t].x || p[t].y || p[t].z)
cnt -= m[inv(p[t])];
}
if(m[p[0]])
cout << 1 << '\n';
else if(cnt)
cout << 2 << '\n';
else if(solve())
cout << 3 << '\n';
else
cout << 0 << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 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 |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 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 |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
2 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
2 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
2 ms |
460 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 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 |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
2 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
2 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
2 ms |
460 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
37 |
Correct |
3 ms |
348 KB |
Output is correct |
38 |
Correct |
3 ms |
344 KB |
Output is correct |
39 |
Correct |
3 ms |
604 KB |
Output is correct |
40 |
Correct |
4 ms |
604 KB |
Output is correct |
41 |
Correct |
4 ms |
604 KB |
Output is correct |
42 |
Correct |
3 ms |
600 KB |
Output is correct |
43 |
Correct |
4 ms |
472 KB |
Output is correct |
44 |
Correct |
5 ms |
604 KB |
Output is correct |
45 |
Correct |
4 ms |
432 KB |
Output is correct |
46 |
Correct |
11 ms |
864 KB |
Output is correct |
47 |
Correct |
13 ms |
1112 KB |
Output is correct |
48 |
Correct |
7 ms |
600 KB |
Output is correct |
49 |
Correct |
8 ms |
604 KB |
Output is correct |
50 |
Correct |
7 ms |
584 KB |
Output is correct |
51 |
Correct |
21 ms |
1096 KB |
Output is correct |
52 |
Correct |
10 ms |
668 KB |
Output is correct |
53 |
Correct |
17 ms |
860 KB |
Output is correct |
54 |
Correct |
15 ms |
856 KB |
Output is correct |
55 |
Correct |
3 ms |
604 KB |
Output is correct |
56 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 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 |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
2 ms |
348 KB |
Output is correct |
24 |
Correct |
0 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
2 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
348 KB |
Output is correct |
34 |
Correct |
2 ms |
460 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
2 ms |
348 KB |
Output is correct |
37 |
Correct |
3 ms |
348 KB |
Output is correct |
38 |
Correct |
3 ms |
344 KB |
Output is correct |
39 |
Correct |
3 ms |
604 KB |
Output is correct |
40 |
Correct |
4 ms |
604 KB |
Output is correct |
41 |
Correct |
4 ms |
604 KB |
Output is correct |
42 |
Correct |
3 ms |
600 KB |
Output is correct |
43 |
Correct |
4 ms |
472 KB |
Output is correct |
44 |
Correct |
5 ms |
604 KB |
Output is correct |
45 |
Correct |
4 ms |
432 KB |
Output is correct |
46 |
Correct |
11 ms |
864 KB |
Output is correct |
47 |
Correct |
13 ms |
1112 KB |
Output is correct |
48 |
Correct |
7 ms |
600 KB |
Output is correct |
49 |
Correct |
8 ms |
604 KB |
Output is correct |
50 |
Correct |
7 ms |
584 KB |
Output is correct |
51 |
Correct |
21 ms |
1096 KB |
Output is correct |
52 |
Correct |
10 ms |
668 KB |
Output is correct |
53 |
Correct |
17 ms |
860 KB |
Output is correct |
54 |
Correct |
15 ms |
856 KB |
Output is correct |
55 |
Correct |
3 ms |
604 KB |
Output is correct |
56 |
Correct |
2 ms |
604 KB |
Output is correct |
57 |
Correct |
6 ms |
708 KB |
Output is correct |
58 |
Correct |
28 ms |
1260 KB |
Output is correct |
59 |
Correct |
29 ms |
1368 KB |
Output is correct |
60 |
Correct |
23 ms |
1204 KB |
Output is correct |
61 |
Correct |
24 ms |
1484 KB |
Output is correct |
62 |
Correct |
29 ms |
1372 KB |
Output is correct |
63 |
Correct |
506 ms |
16872 KB |
Output is correct |
64 |
Correct |
480 ms |
16976 KB |
Output is correct |
65 |
Correct |
480 ms |
14620 KB |
Output is correct |
66 |
Correct |
523 ms |
14676 KB |
Output is correct |
67 |
Correct |
0 ms |
348 KB |
Output is correct |
68 |
Correct |
0 ms |
348 KB |
Output is correct |
69 |
Correct |
549 ms |
24120 KB |
Output is correct |
70 |
Correct |
518 ms |
19536 KB |
Output is correct |
71 |
Correct |
530 ms |
19628 KB |
Output is correct |
72 |
Correct |
417 ms |
15444 KB |
Output is correct |
73 |
Correct |
528 ms |
17496 KB |
Output is correct |