제출 #1185447

#제출 시각아이디문제언어결과실행 시간메모리
1185447steveonalexMixture (BOI20_mixture)C++20
0 / 100
0 ms328 KiB
#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(abs(a), abs(b));}
ll lcm(ll a, ll b){return abs(a) / gcd(a, b) * abs(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());
// mt19937_64 rng(1);
ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);}

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;
    }

pair<ll, ll> get_vector(array<ll, 3> a, array<ll, 3> b){
    ll left = a[0], right = b[0];
    for(ll &i: a) i *= right;
    for(ll &i: b) i *= left;

    pair<ll, ll> lmao = {b[1] - a[1], b[2] - a[2]};
    ll g = gcd(abs(lmao.first), abs(lmao.second));
    if (g != 0){
        lmao.first /= g;
        lmao.second /= g;
    }
    return lmao;
}

int calc(vector<pair<ll, ll>> a){
    for(pair<ll, ll> i: a) if (abs(i.first) + abs(i.second) == 0) return 1;
    for(pair<ll, ll> i: a) for(pair<ll, ll> j: a){
        if (i.first == -j.first && i.second == -j.second) return 2;
    }
    int mask = 0;
    for(pair<ll, ll> i: a){
        if (i.first == 0){
            if (i.second > 0) mask |= 1;
            else mask |= 2;
        }
        if (i.second == 0){
            if (i.first > 0) mask |= 4;
            else mask |= 8;
        }
    }
    for(pair<ll, ll> i: a) for(pair<ll, ll> j: a){
        if (i.first * j.first < 0){
            ll sum = i.second * abs(j.first) + j.second * abs(i.first);
            if (sum > 0) mask |= 1;
            else mask |= 2;
        }
        if (i.second * j.second < 0){
            ll sum = i.first * abs(j.second) + j.first * abs(i.second);
            if (sum > 0) mask |= 4;
            else mask |= 8;
        }
    }
    if ((mask & 3) == 3 || (mask & 12) == 12) return 3;

    return 0;
}

void solve(){
    array<ll, 3> cake;
    for(ll &i: cake)
        cin >> i;

    int idx = max_element(ALL(cake)) - cake.begin();
    swap(cake[0], cake[idx]);

    int q; cin >> q;
    vector<pair<ll, ll>> dude;
    vector<bool> activated;

    ll zero_cnt = 0;
    map<pair<ll, ll>, ll> mp;
    ll pair_cnt = 0;
    ll vector_cnt[4]; memset(vector_cnt, 0, sizeof vector_cnt);
    for(int it = 0; it < q; ++it){
        char type; cin >> type;
        if (type == 'A'){
            array<ll, 3> cur;
            for(ll &i: cur) cin >> i;

            swap(cur[0], cur[idx]);

            pair<ll, ll> vec = get_vector(cake, cur);
            dude.push_back(vec);
            activated.push_back(1);

            if (abs(vec.first) + abs(vec.second) == 0){
                zero_cnt++;
            }
            else{
                mp[vec]++;
                pair<ll, ll> _vec = make_pair(-vec.first, -vec.second);
                pair_cnt += mp[_vec];
            }

            for(int i = 0; i + 1 < (int) dude.size(); ++i) if (activated[i]){
                pair<ll, ll> vcl = dude[i];
                if (vec.first * vcl.first < 0){
                    ll sum = vec.second * abs(vcl.first) + vcl.second * abs(vec.first);
                    if (sum > 0) vector_cnt[0]++;
                    else vector_cnt[1]++;
                }
                if (vec.second * vcl.second < 0){
                    ll sum = vec.first * abs(vcl.second) + vcl.first * abs(vec.second);
                    if (sum > 0) vector_cnt[2]++;
                    else vector_cnt[3]++;
                }
            }
        }
        else{
            int j; cin >> j;
            j--;
            activated[j] = 0;

            pair<ll, ll> vec = dude[j];
            if (abs(vec.first) + abs(vec.second) == 0){
                zero_cnt--;
            }
            else{
                mp[vec]--;
                pair<ll, ll> _vec = make_pair(-vec.first, -vec.second);
                pair_cnt -= mp[_vec];
            }

            for(int i = 0; i < (int) dude.size(); ++i) if (activated[i]){
                pair<ll, ll> vcl = dude[i];
                if (vec.first * vcl.first < 0){
                    ll sum = vec.second * abs(vcl.first) + vcl.second * abs(vec.first);
                    if (sum > 0) vector_cnt[0]--;
                    else vector_cnt[1]--;
                }
                if (vec.second * vcl.second < 0){
                    ll sum = vec.first * abs(vcl.second) + vcl.first * abs(vec.second);
                    if (sum > 0) vector_cnt[2]--;
                    else vector_cnt[3]--;
                }
            }

        }

        if (zero_cnt) cout << 1 << "\n";
        else if (pair_cnt) cout << 2 << "\n";
        else if ((vector_cnt[0] && vector_cnt[1]) || (vector_cnt[2] && vector_cnt[3])) cout << 3 << "\n";
        else cout << 0 << "\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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...