#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MASK(i) (1ULL << (i))
#define GETBIT(mask, i) (((mask) >> (i)) & 1)
#define ALL(v) (v).begin(), (v).end()
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll gcd(ll a, ll b){return __gcd(a, b);}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll LASTBIT(ll mask){return (mask) & (-mask);}
int pop_cnt(ull mask){return __builtin_popcountll(mask);}
int ctz(ull mask){return __builtin_ctzll(mask);}
int logOf(ull mask){return 63 - __builtin_clzll(mask);}
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}
double rngesus_d(double l, double r){
double cur = rngesus(0, MASK(60) - 1);
cur /= MASK(60) - 1;
return l + cur * (r - l);
}
template <class T1, class T2>
bool maximize(T1 &a, T2 b){
if (a < b) {a = b; return true;}
return false;
}
template <class T1, class T2>
bool minimize(T1 &a, T2 b){
if (a > b) {a = b; return true;}
return false;
}
template <class T>
void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){
for(auto item: container) out << item << separator;
out << finish;
}
template <class T>
void remove_dup(vector<T> &a){
sort(ALL(a));
a.resize(unique(ALL(a)) - a.begin());
}
pair<ll, ll> get_vector(ll x, ll y, ll z, ll a, ll b, ll c){
ll _x = x, _a = a;
x *= _a; y *= _a; z *= _a;
a *= _x; b *= _x; c *= _x;
ll f = y - b, s = z - c;
if (f != 0 || s != 0){
ll g = gcd(abs(f), abs(s));
f /= g; s /= g;
}
return make_pair(f, s);
}
ll sign(ll x){return (x > 0) - (x < 0);}
ll calc(vector<pair<ll, ll>> line){
// for(auto i: line) cout << i.first << " " << i.second << "\n";
for(pair<ll, ll> i: line) if (i.first == 0 && i.second == 0) return 1;
int n = line.size();
for(int i = 0; i < n; ++i) for(int j = i+1; j < n; ++j){
if (line[i].first == -line[j].first && line[i].second == -line[j].second)
return 2;
}
// check if ans exist
int mask = 0;
for(int i = 0; i < n; ++i) for(int j = i; j < n; ++j){
pair<ll, ll> x = line[i], y = line[j];
if (i == j){
if (x.second == 0) {
if (x.first > 0) mask |= 4;
else mask |= 8;
}
if (x.first == 0){
if (x.second > 0) mask |= 1;
else mask |= 2;
}
}
if (x.first * y.first < 0){
ll s = x.second * abs(y.first) + y.second * abs(x.first);
if (s > 0) mask |= 1;
else mask |= 2;
}
if (x.second * y.second < 0){
ll s = abs(x.second) * y.first + abs(y.second) * x.first;
if (s > 0) mask |= 4;
else mask |= 8;
}
}
if ((mask & 3) != 3 && (mask & 12) != 12) return 0;
return 3;
}
void solve(){
ll x, y, z; cin >> x >> y >> z;
int n; cin >> n;
vector<pair<ll, ll>> dish(1);
vector<bool> deactivated(1);
for(int i= 1; i <= n; ++i){
char type; cin >> type;
if (type == 'A'){
ll a, b, c; cin >> a >> b >> c;
pair<ll, ll> p = get_vector(x, y, z, a, b, c);
dish.push_back(p);
deactivated.push_back(0);
if (x == 0 && a > 0) deactivated.back() = 1;
if (y == 0 && b > 0) deactivated.back() = 1;
if (z == 0 && c > 0) deactivated.back() = 1;
}
else{
int r; cin >> r;
deactivated[r] = 1;
}
vector<pair<ll, ll>> real;
for(int j = 1; j < (int) dish.size(); ++j) if (!deactivated[j])
real.push_back(dish[j]);
cout << calc(real) << "\n";
}
}
int main(void){
ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
clock_t start = clock();
solve();
cerr << "Time elapsed: " << clock() - start << " ms!\n";
return 0;
}
# | 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... |