#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
typedef long long ll;
using namespace std;
#define double long double
typedef complex<double> pnt;
const double eps = 1e-11;
struct obj {
pnt P;
bool first;
pnt F;
double argF;
double mn, mx;
multiset<double> S;
bool line;
bool zero;
double add(pnt A, double argA)
{
if (!first) {
F = A;
argF = argA;
first = 1;
}
double theta = argA - argF;
if (theta > M_PI)
theta -= 2*M_PI;
if (theta < -M_PI)
theta += 2*M_PI;
S.insert(theta);
if (abs(A.real()) < eps && abs(A.imag()) < eps) {
zero = 1;
return theta;
}
mn = min(mn, theta);
mx = max(mx, theta);
double theta2 = theta;
if (theta > 0)
theta2 -= M_PI;
else
theta2 += M_PI;
auto it = S.lower_bound(theta2-eps);
if (it != S.end() && *it - theta2 < eps)
line = 1;
return theta;
}
int get_ans() {
if (zero)
return 1;
if (line)
return 2;
if (first && mx - mn > M_PI - eps)
return 3;
return 0;
}
};
struct preprocP {
pnt P;
double a;
};
pnt normalize(double x, double y, double z)
{
double sum = x+y+z;
x /= sum;
y /= sum;
return {x, y};
}
pnt P;
const int N = 100'010;
int n;
namespace seg {
vector<preprocP> t[N*4];
void add(int l, int r, const preprocP &P, int i, int b, int e) {
if (l <= b && e <= r) {
t[i].push_back(P);
return;
}
if (r <= b || e <= l)
return;
add(l, r, P, 2*i+1, b, (b+e)/2);
add(l, r, P, 2*i+2, (b+e)/2, e);
}
void add(int l, int r, pnt P) {
preprocP Q;
Q.P = P-::P;
Q.a = arg(Q.P);
add(l, r, Q, 0, 0, n);
}
void dfs(obj &o0, int i, int b, int e) {
multiset<double> marg;
o0.S.swap(marg);
obj o = o0;
o.S.swap(marg);
vector<double> kooft;
for (auto P : t[i])
kooft.push_back(o.add(P.P, P.a));
if (e-b == 1) {
cout << o.get_ans() << '\n';
} else {
dfs(o, 2*i+1, b, (b+e)/2);
dfs(o, 2*i+2, (b+e)/2, e);
}
o.S.swap(marg);
for (auto x : kooft)
marg.erase(marg.find(x));
o0.S.swap(marg);
}
void dfs(pnt P) {
obj o = {};
o.P = P;
dfs(o, 0, 0, n);
}
}
pnt readp()
{
ll x, y, z;
cin >> x >> y >> z;
return normalize(x, y, z);
}
pnt a[N];
int l[N];
bool rem[N];
int main()
{
cin.tie(0) -> sync_with_stdio(false);
P = readp();
cin >> n;
int cnt = 0;
Loop (i,0,n) {
char c;
cin >> c;
if (c == 'A') {
a[cnt] = readp();
l[cnt] = i;
++cnt;
} else {
int x;
cin >> x;
--x;
seg::add(l[x], i, a[x]);
rem[x] = 1;
}
}
Loop (i,0,cnt) {
if (!rem[i])
seg::add(l[i], n, a[i]);
}
seg::dfs(P);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
9684 KB |
Output is correct |
2 |
Correct |
4 ms |
9720 KB |
Output is correct |
3 |
Correct |
4 ms |
9684 KB |
Output is correct |
4 |
Correct |
4 ms |
9736 KB |
Output is correct |
5 |
Correct |
4 ms |
9684 KB |
Output is correct |
6 |
Correct |
4 ms |
9684 KB |
Output is correct |
7 |
Correct |
4 ms |
9684 KB |
Output is correct |
8 |
Correct |
4 ms |
9684 KB |
Output is correct |
9 |
Correct |
4 ms |
9684 KB |
Output is correct |
10 |
Correct |
5 ms |
9740 KB |
Output is correct |
11 |
Correct |
5 ms |
9684 KB |
Output is correct |
12 |
Correct |
4 ms |
9684 KB |
Output is correct |
13 |
Correct |
4 ms |
9684 KB |
Output is correct |
14 |
Correct |
6 ms |
9684 KB |
Output is correct |
15 |
Correct |
6 ms |
9684 KB |
Output is correct |
16 |
Correct |
4 ms |
9684 KB |
Output is correct |
17 |
Correct |
4 ms |
9684 KB |
Output is correct |
18 |
Correct |
6 ms |
9684 KB |
Output is correct |
19 |
Correct |
5 ms |
9684 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
9684 KB |
Output is correct |
2 |
Correct |
4 ms |
9720 KB |
Output is correct |
3 |
Correct |
4 ms |
9684 KB |
Output is correct |
4 |
Correct |
4 ms |
9736 KB |
Output is correct |
5 |
Correct |
4 ms |
9684 KB |
Output is correct |
6 |
Correct |
4 ms |
9684 KB |
Output is correct |
7 |
Correct |
4 ms |
9684 KB |
Output is correct |
8 |
Correct |
4 ms |
9684 KB |
Output is correct |
9 |
Correct |
4 ms |
9684 KB |
Output is correct |
10 |
Correct |
5 ms |
9740 KB |
Output is correct |
11 |
Correct |
5 ms |
9684 KB |
Output is correct |
12 |
Correct |
4 ms |
9684 KB |
Output is correct |
13 |
Correct |
4 ms |
9684 KB |
Output is correct |
14 |
Correct |
6 ms |
9684 KB |
Output is correct |
15 |
Correct |
6 ms |
9684 KB |
Output is correct |
16 |
Correct |
4 ms |
9684 KB |
Output is correct |
17 |
Correct |
4 ms |
9684 KB |
Output is correct |
18 |
Correct |
6 ms |
9684 KB |
Output is correct |
19 |
Correct |
5 ms |
9684 KB |
Output is correct |
20 |
Correct |
4 ms |
9676 KB |
Output is correct |
21 |
Correct |
5 ms |
9684 KB |
Output is correct |
22 |
Correct |
4 ms |
9812 KB |
Output is correct |
23 |
Correct |
5 ms |
9812 KB |
Output is correct |
24 |
Correct |
5 ms |
9904 KB |
Output is correct |
25 |
Correct |
6 ms |
9812 KB |
Output is correct |
26 |
Correct |
5 ms |
9812 KB |
Output is correct |
27 |
Correct |
5 ms |
9884 KB |
Output is correct |
28 |
Correct |
5 ms |
9848 KB |
Output is correct |
29 |
Correct |
5 ms |
9812 KB |
Output is correct |
30 |
Correct |
5 ms |
9812 KB |
Output is correct |
31 |
Correct |
5 ms |
9712 KB |
Output is correct |
32 |
Correct |
6 ms |
9812 KB |
Output is correct |
33 |
Correct |
5 ms |
9812 KB |
Output is correct |
34 |
Correct |
6 ms |
9812 KB |
Output is correct |
35 |
Correct |
5 ms |
9812 KB |
Output is correct |
36 |
Correct |
5 ms |
9848 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
9684 KB |
Output is correct |
2 |
Correct |
4 ms |
9720 KB |
Output is correct |
3 |
Correct |
4 ms |
9684 KB |
Output is correct |
4 |
Correct |
4 ms |
9736 KB |
Output is correct |
5 |
Correct |
4 ms |
9684 KB |
Output is correct |
6 |
Correct |
4 ms |
9684 KB |
Output is correct |
7 |
Correct |
4 ms |
9684 KB |
Output is correct |
8 |
Correct |
4 ms |
9684 KB |
Output is correct |
9 |
Correct |
4 ms |
9684 KB |
Output is correct |
10 |
Correct |
5 ms |
9740 KB |
Output is correct |
11 |
Correct |
5 ms |
9684 KB |
Output is correct |
12 |
Correct |
4 ms |
9684 KB |
Output is correct |
13 |
Correct |
4 ms |
9684 KB |
Output is correct |
14 |
Correct |
6 ms |
9684 KB |
Output is correct |
15 |
Correct |
6 ms |
9684 KB |
Output is correct |
16 |
Correct |
4 ms |
9684 KB |
Output is correct |
17 |
Correct |
4 ms |
9684 KB |
Output is correct |
18 |
Correct |
6 ms |
9684 KB |
Output is correct |
19 |
Correct |
5 ms |
9684 KB |
Output is correct |
20 |
Correct |
4 ms |
9676 KB |
Output is correct |
21 |
Correct |
5 ms |
9684 KB |
Output is correct |
22 |
Correct |
4 ms |
9812 KB |
Output is correct |
23 |
Correct |
5 ms |
9812 KB |
Output is correct |
24 |
Correct |
5 ms |
9904 KB |
Output is correct |
25 |
Correct |
6 ms |
9812 KB |
Output is correct |
26 |
Correct |
5 ms |
9812 KB |
Output is correct |
27 |
Correct |
5 ms |
9884 KB |
Output is correct |
28 |
Correct |
5 ms |
9848 KB |
Output is correct |
29 |
Correct |
5 ms |
9812 KB |
Output is correct |
30 |
Correct |
5 ms |
9812 KB |
Output is correct |
31 |
Correct |
5 ms |
9712 KB |
Output is correct |
32 |
Correct |
6 ms |
9812 KB |
Output is correct |
33 |
Correct |
5 ms |
9812 KB |
Output is correct |
34 |
Correct |
6 ms |
9812 KB |
Output is correct |
35 |
Correct |
5 ms |
9812 KB |
Output is correct |
36 |
Correct |
5 ms |
9848 KB |
Output is correct |
37 |
Correct |
6 ms |
9772 KB |
Output is correct |
38 |
Correct |
5 ms |
9880 KB |
Output is correct |
39 |
Correct |
7 ms |
9940 KB |
Output is correct |
40 |
Correct |
6 ms |
10032 KB |
Output is correct |
41 |
Correct |
8 ms |
9912 KB |
Output is correct |
42 |
Correct |
6 ms |
10012 KB |
Output is correct |
43 |
Correct |
7 ms |
10068 KB |
Output is correct |
44 |
Correct |
6 ms |
10068 KB |
Output is correct |
45 |
Correct |
7 ms |
10084 KB |
Output is correct |
46 |
Correct |
14 ms |
11092 KB |
Output is correct |
47 |
Correct |
15 ms |
11140 KB |
Output is correct |
48 |
Correct |
6 ms |
9940 KB |
Output is correct |
49 |
Correct |
8 ms |
10392 KB |
Output is correct |
50 |
Correct |
8 ms |
10460 KB |
Output is correct |
51 |
Correct |
14 ms |
11476 KB |
Output is correct |
52 |
Correct |
17 ms |
11988 KB |
Output is correct |
53 |
Correct |
18 ms |
12116 KB |
Output is correct |
54 |
Correct |
19 ms |
12108 KB |
Output is correct |
55 |
Correct |
19 ms |
11488 KB |
Output is correct |
56 |
Correct |
19 ms |
11372 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
9684 KB |
Output is correct |
2 |
Correct |
4 ms |
9720 KB |
Output is correct |
3 |
Correct |
4 ms |
9684 KB |
Output is correct |
4 |
Correct |
4 ms |
9736 KB |
Output is correct |
5 |
Correct |
4 ms |
9684 KB |
Output is correct |
6 |
Correct |
4 ms |
9684 KB |
Output is correct |
7 |
Correct |
4 ms |
9684 KB |
Output is correct |
8 |
Correct |
4 ms |
9684 KB |
Output is correct |
9 |
Correct |
4 ms |
9684 KB |
Output is correct |
10 |
Correct |
5 ms |
9740 KB |
Output is correct |
11 |
Correct |
5 ms |
9684 KB |
Output is correct |
12 |
Correct |
4 ms |
9684 KB |
Output is correct |
13 |
Correct |
4 ms |
9684 KB |
Output is correct |
14 |
Correct |
6 ms |
9684 KB |
Output is correct |
15 |
Correct |
6 ms |
9684 KB |
Output is correct |
16 |
Correct |
4 ms |
9684 KB |
Output is correct |
17 |
Correct |
4 ms |
9684 KB |
Output is correct |
18 |
Correct |
6 ms |
9684 KB |
Output is correct |
19 |
Correct |
5 ms |
9684 KB |
Output is correct |
20 |
Correct |
4 ms |
9676 KB |
Output is correct |
21 |
Correct |
5 ms |
9684 KB |
Output is correct |
22 |
Correct |
4 ms |
9812 KB |
Output is correct |
23 |
Correct |
5 ms |
9812 KB |
Output is correct |
24 |
Correct |
5 ms |
9904 KB |
Output is correct |
25 |
Correct |
6 ms |
9812 KB |
Output is correct |
26 |
Correct |
5 ms |
9812 KB |
Output is correct |
27 |
Correct |
5 ms |
9884 KB |
Output is correct |
28 |
Correct |
5 ms |
9848 KB |
Output is correct |
29 |
Correct |
5 ms |
9812 KB |
Output is correct |
30 |
Correct |
5 ms |
9812 KB |
Output is correct |
31 |
Correct |
5 ms |
9712 KB |
Output is correct |
32 |
Correct |
6 ms |
9812 KB |
Output is correct |
33 |
Correct |
5 ms |
9812 KB |
Output is correct |
34 |
Correct |
6 ms |
9812 KB |
Output is correct |
35 |
Correct |
5 ms |
9812 KB |
Output is correct |
36 |
Correct |
5 ms |
9848 KB |
Output is correct |
37 |
Correct |
6 ms |
9772 KB |
Output is correct |
38 |
Correct |
5 ms |
9880 KB |
Output is correct |
39 |
Correct |
7 ms |
9940 KB |
Output is correct |
40 |
Correct |
6 ms |
10032 KB |
Output is correct |
41 |
Correct |
8 ms |
9912 KB |
Output is correct |
42 |
Correct |
6 ms |
10012 KB |
Output is correct |
43 |
Correct |
7 ms |
10068 KB |
Output is correct |
44 |
Correct |
6 ms |
10068 KB |
Output is correct |
45 |
Correct |
7 ms |
10084 KB |
Output is correct |
46 |
Correct |
14 ms |
11092 KB |
Output is correct |
47 |
Correct |
15 ms |
11140 KB |
Output is correct |
48 |
Correct |
6 ms |
9940 KB |
Output is correct |
49 |
Correct |
8 ms |
10392 KB |
Output is correct |
50 |
Correct |
8 ms |
10460 KB |
Output is correct |
51 |
Correct |
14 ms |
11476 KB |
Output is correct |
52 |
Correct |
17 ms |
11988 KB |
Output is correct |
53 |
Correct |
18 ms |
12116 KB |
Output is correct |
54 |
Correct |
19 ms |
12108 KB |
Output is correct |
55 |
Correct |
19 ms |
11488 KB |
Output is correct |
56 |
Correct |
19 ms |
11372 KB |
Output is correct |
57 |
Correct |
24 ms |
12144 KB |
Output is correct |
58 |
Correct |
18 ms |
12164 KB |
Output is correct |
59 |
Correct |
19 ms |
12168 KB |
Output is correct |
60 |
Correct |
26 ms |
12120 KB |
Output is correct |
61 |
Correct |
78 ms |
20076 KB |
Output is correct |
62 |
Correct |
72 ms |
20100 KB |
Output is correct |
63 |
Correct |
471 ms |
65188 KB |
Output is correct |
64 |
Correct |
472 ms |
65200 KB |
Output is correct |
65 |
Correct |
416 ms |
54048 KB |
Output is correct |
66 |
Correct |
397 ms |
55708 KB |
Output is correct |
67 |
Correct |
5 ms |
9728 KB |
Output is correct |
68 |
Correct |
4 ms |
9724 KB |
Output is correct |
69 |
Correct |
536 ms |
68240 KB |
Output is correct |
70 |
Correct |
482 ms |
61024 KB |
Output is correct |
71 |
Correct |
457 ms |
60900 KB |
Output is correct |
72 |
Correct |
485 ms |
67136 KB |
Output is correct |
73 |
Correct |
519 ms |
67208 KB |
Output is correct |