#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-5, pi = acos(-1);
bool eq (double a, double b) {
return abs(a-b)<=eps;
}
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,b=0, bud[n+1] = {}, p[n+1] = {};
multiset<double> st3;
set<pair<double,int>> st2;
double ang[n+1] = {};
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);
st3.insert(ang[id]);
auto it = st2.lower_bound({fmod(ang[id]+pi,2*pi), 0});
if (it!=st2.end() && eq((*it).fi,fmod(ang[id]+pi,2*pi))) {
bud[id] = (*it).se;
bud[(*it).se] = id;
st2.erase(it);
b++;
}
else st2.insert({ang[id],id});
}
++id;
}
else {
int x; cin >> x;
st3.erase(ang[x]);
a -= p[x];
if (bud[x]) {
bud[bud[x]] = 0;
b--;
auto it = st2.lower_bound({fmod(ang[bud[x]]+pi,2*pi), 0});
if (it!=st2.end() && eq((*it).fi,ang[bud[x]])) {
bud[bud[x]] = (*it).se;
bud[(*it).se] = bud[x];
st2.erase(it);
b++;
}
else st2.insert({ang[bud[x]],bud[x]});
bud[x] = 0;
}
}
bool c = 0;
if (len(st3)>2) {
double un = (*st3.begin());
double dos = (*--st3.upper_bound(un+pi+eps));
double tres = (*--st3.upper_bound(dos+pi+eps));
if (min(dos-un,min(tres-dos,2*pi-un-tres))<=pi+eps) 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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
324 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |