제출 #1185354

#제출 시각아이디문제언어결과실행 시간메모리
1185354steveonalexMixture (BOI20_mixture)C++20
30 / 100
2096 ms584 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;

    for(int i = 0; i < q; ++i){
        char type; cin >> type;
        if (type == 'A'){
            array<ll, 3> cur;
            for(ll &i: cur) cin >> i;

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

            dude.push_back(get_vector(cake, cur));
            activated.push_back(1);
        }
        else{
            int j; cin >> j;
            activated[j-1] = 0;
        }

        vector<pair<ll, ll>> cuoi;
        for(int j = 0; j < (int) dude.size(); ++j) if (activated[j]){
            cuoi.push_back(dude[j]);
        }

        cout << calc(cuoi) << "\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...