#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define pi pair<__int128,__int128>
constexpr int maxn = 502;
int it;
pi x[maxn], y[maxn];
bool del[maxn];
__int128 krata(__int128 x)
{
if(x < 0) return x*(-1);
return x;
}
pi skr(pi a)
{
__int128 nwd = __gcd(krata(a.f),krata(a.s));
a.f /= nwd; a.s /= nwd;
if(a.s < 0) a.f *= (__int128)(-1), a.s *= (__int128)(-1);
return a;
}
int comp(pi a, pi b)
{
__int128 val = a.f*b.s-b.f*a.s;
if(val > 0) return 1;
if(val == 0) return 0;
return -1;
}
pi D(pi a, pi b)
{
return skr({a.f*b.s-b.f*a.s,a.s*b.s});
}
pi M(pi a, pi b)
{
return skr({a.f*b.f,a.s*b.s});
}
pi C(int p, int a, int b)
{
return D(M(D(x[a],x[p]),D(y[b],y[p])),M(D(x[b],x[p]),D(y[a],y[p])));
}
int check()
{
for(int i=1; i<=it; i++)
if(!del[i] && x[i]==x[0] && y[i]==y[0]) return 1;
for(int i=1; i<=it; i++)
{
if(del[i]) continue;
for(int j=i+1; j<=it; j++)
{
if(del[j]) continue;
if(C(i,0,j).first) continue;
if(comp(x[0],x[i]) == comp(x[0],x[j])
&& comp(x[0],x[i]) != 0) continue;
if(comp(y[0],y[i]) == comp(y[0],y[j])
&& comp(y[0],y[i]) != 0) continue;
return 2;
}
}
for(int i=1; i<=it; i++)
{
if(del[i]) continue;
for(int j=i+1; j<=it; j++)
{
if(del[j]) continue;
for(int k=j+1; k<=it; k++)
{
if(del[k]) continue;
ll c1 = C(0,i,j).first;
ll c2 = C(0,j,k).first;
ll c3 = C(0,k,i).first;
if(c1 > 0 && c2 > 0 && c3 > 0) return 3;
if(c1 < 0 && c2 < 0 && c3 < 0) return 3;
}
}
}
return 0;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll S,P,G,n; cin >> S >> P >> G >> n;
x[0] = skr({(__int128)S,(__int128)(S+P+G)});
y[0] = skr({(__int128)P,(__int128)(S+P+G)});
while(n--)
{
char ch; cin >> ch;
if(ch == 'A')
{
ll A,B,C; cin >> A >> B >> C;
x[++it] = skr({(__int128)A,(__int128)(A+B+C)});
y[it] = skr({(__int128)B,(__int128)(A+B+C)});
}
else
{
int i; cin >> i;
del[i]=1;
}
cout << check() << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |