#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,e) for (int i = s; i <= e; ++i)
#define rrep(i,s,e) for (int i = s; i >= e; --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define len(a) (int)a.size()
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
const double eps = 1e-10, pi = acos(-1);
const int mx = 1e5;
bool eq (double a, double b) {
return abs(a-b)<=5*eps;
}
double ang[mx+1] = {};
int bud[mx+1] = {}, b = 0;
set<pair<double,int>> st2;
void do_two (int id) {
double poss[5] = {fmod(ang[id]+pi+eps,2*pi),
ang[id]+pi-eps,
fmod(ang[id]+pi-eps,2*pi),
fmod(ang[id]+pi,2*pi)+eps,
fmod(ang[id]+pi,2*pi)-eps};
rep (i,0,4) {
double pos = poss[i];
auto it = st2.lower_bound({pos, 0});
if (it!=st2.end() && eq((*it).fi,pos)) {
bud[id] = (*it).se;
bud[(*it).se] = id;
st2.erase(it);
b++;
return;
}
}
st2.insert({ang[id], id});
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
double S, P, G; cin >> S >> P >> G;
double X = S/(S+P+G), Y = P/(S+P+G);
int n; cin >>n;
int id = 1, a=0, p[n+1] = {};
multiset<double> st3;
rep (i,1,n) {
char tp; cin >> tp;
if (tp=='A') {
double Si, Pi, Gi;
cin >> Si >> Pi >> Gi;
double x = Si/(Si+Pi+Gi), y = Pi/(Si+Pi+Gi);
if (eq(X,x) && eq(Y,y)) {
a++;
p[id] = 1;
}
else {
ang[id] = fmod(pi+atan2(y-Y, x-X),2*pi);
// cout << "ang #" << id << ": " << ang[id] << endl;
st3.insert(ang[id]);
do_two(id);
}
++id;
}
else {
int x; cin >> x;
if (p[x])
a--;
else {
st3.erase(st3.find(ang[x]));
if (st2.find({ang[x],x})!=st2.end()) st2.erase({ang[x],x});
if (bud[x]) {
b--;
bud[bud[x]] = 0;
do_two(bud[x]);
bud[x] = 0;
}
}
}
//cout << i << " " << b << endl;
bool c = 0;
if (len(st3)>2) {
double un = (*st3.begin());
double dos = (*--st3.upper_bound(un+pi));
double tres = (*--st3.upper_bound(dos+pi));
if (max(dos-un,max(tres-dos,2*pi+un-tres))<=pi) c = 1;
}
if (a) cout << "1\n";
else if (b) cout << "2\n";
else if (c) cout << "3\n";
else cout << "0\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
272 KB |
Output is correct |
21 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
2 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 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 |
1 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 |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
272 KB |
Output is correct |
21 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
2 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 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 |
1 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 |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
2 ms |
340 KB |
Output is correct |
40 |
Correct |
2 ms |
340 KB |
Output is correct |
41 |
Correct |
2 ms |
340 KB |
Output is correct |
42 |
Correct |
1 ms |
340 KB |
Output is correct |
43 |
Correct |
2 ms |
340 KB |
Output is correct |
44 |
Correct |
2 ms |
340 KB |
Output is correct |
45 |
Correct |
2 ms |
340 KB |
Output is correct |
46 |
Correct |
5 ms |
564 KB |
Output is correct |
47 |
Correct |
4 ms |
468 KB |
Output is correct |
48 |
Correct |
2 ms |
340 KB |
Output is correct |
49 |
Correct |
3 ms |
340 KB |
Output is correct |
50 |
Correct |
2 ms |
340 KB |
Output is correct |
51 |
Correct |
5 ms |
564 KB |
Output is correct |
52 |
Correct |
6 ms |
724 KB |
Output is correct |
53 |
Correct |
6 ms |
840 KB |
Output is correct |
54 |
Correct |
6 ms |
852 KB |
Output is correct |
55 |
Correct |
4 ms |
340 KB |
Output is correct |
56 |
Correct |
4 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 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 |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
272 KB |
Output is correct |
21 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
2 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 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 |
1 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 |
1 ms |
340 KB |
Output is correct |
35 |
Correct |
1 ms |
340 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
2 ms |
340 KB |
Output is correct |
40 |
Correct |
2 ms |
340 KB |
Output is correct |
41 |
Correct |
2 ms |
340 KB |
Output is correct |
42 |
Correct |
1 ms |
340 KB |
Output is correct |
43 |
Correct |
2 ms |
340 KB |
Output is correct |
44 |
Correct |
2 ms |
340 KB |
Output is correct |
45 |
Correct |
2 ms |
340 KB |
Output is correct |
46 |
Correct |
5 ms |
564 KB |
Output is correct |
47 |
Correct |
4 ms |
468 KB |
Output is correct |
48 |
Correct |
2 ms |
340 KB |
Output is correct |
49 |
Correct |
3 ms |
340 KB |
Output is correct |
50 |
Correct |
2 ms |
340 KB |
Output is correct |
51 |
Correct |
5 ms |
564 KB |
Output is correct |
52 |
Correct |
6 ms |
724 KB |
Output is correct |
53 |
Correct |
6 ms |
840 KB |
Output is correct |
54 |
Correct |
6 ms |
852 KB |
Output is correct |
55 |
Correct |
4 ms |
340 KB |
Output is correct |
56 |
Correct |
4 ms |
468 KB |
Output is correct |
57 |
Correct |
7 ms |
468 KB |
Output is correct |
58 |
Correct |
7 ms |
468 KB |
Output is correct |
59 |
Correct |
8 ms |
468 KB |
Output is correct |
60 |
Correct |
8 ms |
528 KB |
Output is correct |
61 |
Correct |
32 ms |
2224 KB |
Output is correct |
62 |
Correct |
28 ms |
2260 KB |
Output is correct |
63 |
Correct |
168 ms |
8748 KB |
Output is correct |
64 |
Correct |
146 ms |
8804 KB |
Output is correct |
65 |
Correct |
130 ms |
3556 KB |
Output is correct |
66 |
Correct |
177 ms |
5108 KB |
Output is correct |
67 |
Correct |
1 ms |
212 KB |
Output is correct |
68 |
Correct |
0 ms |
324 KB |
Output is correct |
69 |
Correct |
193 ms |
11724 KB |
Output is correct |
70 |
Correct |
169 ms |
8904 KB |
Output is correct |
71 |
Correct |
213 ms |
8908 KB |
Output is correct |
72 |
Correct |
143 ms |
10948 KB |
Output is correct |
73 |
Correct |
163 ms |
10572 KB |
Output is correct |