#include <bits/stdc++.h>
#define int long long
using namespace std;
struct V3d{
int x, y, z;
void norm(){
int g = __gcd(__gcd(x, y), z); g = abs(g);
if(g != 0) x /= g, y /= g, z /= g;
}
bool operator< (const V3d o) const {
if(x != o.x) return x < o.x;
if(y != o.y) return y < o.y;
if(z != o.z) return z < o.z;
return 0;
}
};
int dot(V3d a, V3d b){
return a.x * b.x + a.y * b.y + a.z * b.z;
}
__int128_t dot128(V3d a, V3d b){
return (__int128_t) a.x * b.x + (__int128_t) a.y * b.y + (__int128_t) a.z * b.z;
}
long double triple(V3d a, V3d b, V3d c){
long double r = 0;
r += (long double) a.x * b.y * c.z;
r += (long double) a.z * b.x * c.y;
r += (long double) a.y * b.z * c.x;
r -= (long double) a.x * b.z * c.y;
r -= (long double) a.y * b.x * c.z;
r -= (long double) a.z * b.y * c.x;
return r;
}
V3d operator* (V3d a, int n){
return {a.x * n, a.y * n, a.z * n};
}
V3d operator- (V3d a, V3d b){
return {a.x - b.x, a.y - b.y, a.z - b.z};
}
V3d operator- (V3d b){
return {-b.x, -b.y, -b.z};
}
V3d vds[100011]; int ai = 0;
V3d f;
long double deg(V3d a, V3d b){
__int128_t p = dot128(a, b);
long double q = sqrt((long double) dot128(a, a)) * sqrt((long double) dot128(b, b));
return acos(min(1.0L, (long double) p / q)) * (triple(f, a, b) > 0 ? 1 : -1);
}
const long double PI = 3.1415926535;
struct Angle{
bool init = false;
multiset<long double> S;
void add(long double d){
S.insert(d);
}
void rem(long double d){
S.erase(S.find(d));
}
bool qry(){
if(!init) return false;
if(S.size() < 3) return false;
uniform_real_distribution<long double> dist(-PI, PI);
random_device rd;
long double diff = *S.begin() + PI * 2 - *prev(S.end());
if(diff > PI) return false;
auto ptr = S.lower_bound(*S.begin() + PI);
if(ptr != S.end() && prev(ptr) == S.begin()) return false;
ptr--; if(*next(ptr) - *ptr > PI) return false;
return true;
}
} Solver;
struct Handle{
int c1 = 0, c2 = 0; map<V3d, int> cnt;
V3d o;
void add(V3d a){
a.norm();
if(a.x == 0 && a.y == 0 && a.z == 0) { c1++; return; }
if(!Solver.init){
Solver.init = true;
o = a; Solver.add(deg(o, a));
}else{
Solver.add(deg(o, a));
}
cnt[a]++; if(cnt[a] == 1 && cnt[-a] > 0) c2++;
}
void rem(V3d a){
a.norm();
if(a.x == 0 && a.y == 0 && a.z == 0) { c1--; return; }
Solver.rem(deg(o, a));
cnt[a]--; if(cnt[a] == 0 && cnt[-a] > 0) c2--;
}
int qry(){
if(c1 > 0) return 1;
if(c2 > 0) return 2;
if(Solver.qry()) return 3;
return 0;
}
} handle;
int32_t main(){
cin.tie(0); cout.tie(0)->sync_with_stdio(false);
int x, y, z; cin >> x >> y >> z; f = V3d {x, y, z};
int n; cin >> n;
for(int i = 0; i < n; i++){
char c; cin >> c;
if(c == 'A'){
int x, y, z; cin >> x >> y >> z;
V3d a {x, y, z};
vds[++ai] = a * dot(f, f) - f * dot(a, f);
handle.add(vds[ai]);
}else{
int x; cin >> x;
handle.rem(vds[x]);
}
cout << handle.qry() << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
2 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
2 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
2 ms |
340 KB |
Output is correct |
37 |
Correct |
3 ms |
340 KB |
Output is correct |
38 |
Correct |
3 ms |
340 KB |
Output is correct |
39 |
Correct |
2 ms |
468 KB |
Output is correct |
40 |
Correct |
3 ms |
468 KB |
Output is correct |
41 |
Correct |
3 ms |
468 KB |
Output is correct |
42 |
Correct |
3 ms |
468 KB |
Output is correct |
43 |
Correct |
3 ms |
468 KB |
Output is correct |
44 |
Correct |
3 ms |
468 KB |
Output is correct |
45 |
Correct |
3 ms |
392 KB |
Output is correct |
46 |
Correct |
4 ms |
724 KB |
Output is correct |
47 |
Correct |
12 ms |
820 KB |
Output is correct |
48 |
Correct |
6 ms |
340 KB |
Output is correct |
49 |
Correct |
8 ms |
340 KB |
Output is correct |
50 |
Correct |
7 ms |
340 KB |
Output is correct |
51 |
Correct |
18 ms |
852 KB |
Output is correct |
52 |
Correct |
5 ms |
596 KB |
Output is correct |
53 |
Correct |
18 ms |
912 KB |
Output is correct |
54 |
Correct |
18 ms |
924 KB |
Output is correct |
55 |
Correct |
2 ms |
460 KB |
Output is correct |
56 |
Correct |
3 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
0 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
1 ms |
340 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
1 ms |
212 KB |
Output is correct |
34 |
Correct |
2 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
2 ms |
340 KB |
Output is correct |
37 |
Correct |
3 ms |
340 KB |
Output is correct |
38 |
Correct |
3 ms |
340 KB |
Output is correct |
39 |
Correct |
2 ms |
468 KB |
Output is correct |
40 |
Correct |
3 ms |
468 KB |
Output is correct |
41 |
Correct |
3 ms |
468 KB |
Output is correct |
42 |
Correct |
3 ms |
468 KB |
Output is correct |
43 |
Correct |
3 ms |
468 KB |
Output is correct |
44 |
Correct |
3 ms |
468 KB |
Output is correct |
45 |
Correct |
3 ms |
392 KB |
Output is correct |
46 |
Correct |
4 ms |
724 KB |
Output is correct |
47 |
Correct |
12 ms |
820 KB |
Output is correct |
48 |
Correct |
6 ms |
340 KB |
Output is correct |
49 |
Correct |
8 ms |
340 KB |
Output is correct |
50 |
Correct |
7 ms |
340 KB |
Output is correct |
51 |
Correct |
18 ms |
852 KB |
Output is correct |
52 |
Correct |
5 ms |
596 KB |
Output is correct |
53 |
Correct |
18 ms |
912 KB |
Output is correct |
54 |
Correct |
18 ms |
924 KB |
Output is correct |
55 |
Correct |
2 ms |
460 KB |
Output is correct |
56 |
Correct |
3 ms |
468 KB |
Output is correct |
57 |
Correct |
4 ms |
468 KB |
Output is correct |
58 |
Correct |
25 ms |
1120 KB |
Output is correct |
59 |
Correct |
25 ms |
1108 KB |
Output is correct |
60 |
Correct |
7 ms |
980 KB |
Output is correct |
61 |
Correct |
14 ms |
1672 KB |
Output is correct |
62 |
Correct |
67 ms |
1752 KB |
Output is correct |
63 |
Correct |
420 ms |
14924 KB |
Output is correct |
64 |
Correct |
419 ms |
15688 KB |
Output is correct |
65 |
Correct |
337 ms |
12852 KB |
Output is correct |
66 |
Correct |
397 ms |
12876 KB |
Output is correct |
67 |
Correct |
0 ms |
212 KB |
Output is correct |
68 |
Correct |
1 ms |
332 KB |
Output is correct |
69 |
Correct |
440 ms |
22808 KB |
Output is correct |
70 |
Correct |
402 ms |
18512 KB |
Output is correct |
71 |
Correct |
404 ms |
18440 KB |
Output is correct |
72 |
Correct |
145 ms |
15756 KB |
Output is correct |
73 |
Correct |
426 ms |
17260 KB |
Output is correct |