Submission #685128

# Submission time Handle Problem Language Result Execution time Memory
685128 2023-01-23T14:24:23 Z stanislavpolyn Mixture (BOI20_mixture) C++17
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>

#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
#define rf(i, a, b) for (int i = (a); i >= (b); --i)
#define fe(x, y) for (auto& x : y)

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define pw(x) (1LL << (x))

using namespace std;

mt19937_64 rng(228);

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fbo find_by_order
#define ook order_of_key

template <typename T>
bool umx(T& a, T b) {
    return a < b ? a = b, 1 : 0;
}
template <typename T>
bool umn(T& a, T b) {
    return a > b ? a = b, 1 : 0;
}

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
using ve = vector<T>;

const int N = 2e5 + 5;

const ld EPS = 1e-10;

array<int, 3> a;
ve<array<int, 3>> all;
bool del[N];

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios::sync_with_stdio(0);
    cin.tie(0);
#endif

    fr (i, 0, 2) cin >> a[i];
    int g = __gcd(__gcd(a[0], a[1]), a[2]);
    if (g) {
        fr (i, 0, 2) a[i] /= g;
    }

    int q;
    cin >> q;

    fr (i, 1, q) {
        char c;
        cin >> c;

        if (c == 'A') {
            int x, y, z;
            cin >> x >> y >> z;
            int g = __gcd(__gcd(x, y), z);
            if (g) {
                x /= g;
                y /= g;
                z /= g;
            }
            all.pb({x, y, z});
        } else {
            int idx;
            cin >> idx;
            del[idx - 1] = 1;
        }

        bool found = 0;
        fr (p, 0, sz(all) - 1) {
            if (del[p]) continue;
            if (all[p] == a) {
                cout << "1\n";
                found = 1;
                break;
            }
        }
        if (found) {
            continue;
        }

        fr (p1, 0, sz(all) - 1) {
            if (del[p1]) continue;
            fr (p2, 0, sz(all) - 1) {
                if (p1 == p2) continue;
                if (del[p2]) continue;

//                cout << "CHECK " << p1 << " " << p2 << "\n";
                bool ok = 1;
                fr (i, 0, 2) {
                    ld L = all[p1][i] / ld(all[p1][0] + all[p1][1] + all[p1][2]);
                    ld R = all[p2][i] / ld(all[p2][0] + all[p2][1] + all[p2][2]);
                    ld x = a[i] / ld(a[0] + a[1] + a[2]);

//                    cout << x << " " << L << " " << R << "\n";
                    ok &= x + EPS >= min(L, R) && x - EPS <= max(L, R);
                }

                if (ok) {
                    cout << "2\n";
                    found = 1;
                    break;
                }
            }
            if (found) {
                break;
            }
        }

        if (found) {
            continue;
        }

        fr (p1, 0, sz(all) - 1) {
            if (del[p1]) continue;
            fr (p2, 0, sz(all) - 1) {
                if (p1 == p2) continue;
                if (del[p2]) continue;

                fr (p3, 0, sz(all) - 1) {
                    if (p3 == p2 || p3 == p1) continue;
                    if (del[p3]) continue;

                    bool ok = 1;
                    fr (i, 0, 2) {
                        ld L = all[p1][i] / ld(all[p1][0] + all[p1][1] + all[p1][2]);
                        ld R = all[p2][i] / ld(all[p2][0] + all[p2][1] + all[p2][2]);
                        ld P = all[p3][i] / ld(all[p3][0] + all[p3][1] + all[p3][2]);
                        ld x = a[i] / ld(a[0] + a[1] + a[2]);

    //                    cout << x << " " << L << " " << R << "\n";
                        ok &= x + EPS >= min({L, R, P}) && x - EPS <= max({L, R, P});
                    }

                    if (ok) {
                        cout << "3\n";
                        found = 1;
                        break;
                    }
                }
                if (found) {
                    break;
                }
            }
            if (found) {
                break;
            }
        }


        if (found) {
            continue;
        }

        fr (p1, 0, sz(all) - 1) {
            if (del[p1]) continue;
            fr (p2, 0, sz(all) - 1) {
                if (p1 == p2) continue;
                if (del[p2]) continue;

                fr (p3, 0, sz(all) - 1) {
                    if (p3 == p2 || p3 == p1) continue;
                    if (del[p3]) continue;

                    fr (p4, 0, sz(all) - 1) {
                        if (p4 == p3 || p4 == p2 || p4 == p1) continue;
                        if (del[p4]) continue;

                        bool ok = 1;
                        fr (i, 0, 2) {
                            ld L = all[p1][i] / ld(all[p1][0] + all[p1][1] + all[p1][2]);
                            ld R = all[p2][i] / ld(all[p2][0] + all[p2][1] + all[p2][2]);
                            ld P = all[p3][i] / ld(all[p3][0] + all[p3][1] + all[p3][2]);
                            ld Q = all[p4][i] / ld(all[p4][0] + all[p4][1] + all[p4][2]);
                            ld x = a[i] / ld(a[0] + a[1] + a[2]);

        //                    cout << x << " " << L << " " << R << "\n";
                            ok &= x + EPS >= min({L, R, P, Q}) && x - EPS <= max({L, R, P, Q});
                        }

                        if (ok) {
                            cout << "4\n";
                            found = 1;
                            break;
                        }
                    }
                }
                if (found) {
                    break;
                }
            }
            if (found) {
                break;
            }
        }


        if (!found) {
            cout << "0\n";
        }
    }



    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -