제출 #529151

#제출 시각아이디문제언어결과실행 시간메모리
529151c28dnv9q3Mixture (BOI20_mixture)C++17
0 / 100
1 ms288 KiB
#include <iostream> #include <bits/stdc++.h> #define lli long long int using namespace std; lli mod = 1000000007; lli pow(lli b, lli e) { if (e == 0) return 1; lli h = pow(b, e / 2); return ((((e % 2 == 1 ? b : 1) * h) % mod) * h) % mod; } lli inv(lli n) { return pow(n, mod - 2); } struct frac { lli z; lli d; lli t; bool operator < (const frac& other) const { if (z * other.d == other.z * d) return t < other.t; return z * other.d < other.z * d; } bool operator > (const frac& other) const { if (z * other.d == other.z * d) return t > other.t; return z * other.d > other.z * d; } bool operator <= (const frac& other) const { return z * other.d <= other.z * d; } bool operator >= (const frac& other) const { return z * other.d >= other.z * d; } frac operator - () const { return frac({-z, d, t}); } }; template <class T> struct les { bool operator() (const T& x, const T& y) const { return x < y; } typedef T first_argument_type; typedef T second_argument_type; typedef bool result_type; }; std::ostream & operator<<(std::ostream & Str, frac const & v) { Str << v.z << " " << v.d; return Str; } int main() { lli a, b, c; cin >> a >> b >> c; lli n; cin >> n; multiset<frac, les<frac>> pos, neg; vector<frac> regal; string op; lli ta, tb, tc, r, z; frac f; z = 0; for (int i = 0; i < n; ++i) { //cout << i << "\n"; cin >> op; if (op == "A") { cin >> ta >> tb >> tc; ta *= a; tb *= a; tc *= a; tb -= ta / a * b; tc -= ta / a * c; f = frac({tb, tc, i}); regal.push_back(f); if (f.z == 0 && f.d == 0) { z++; } else { if (f.d >= 0) { pos.insert(f); } else { neg.insert(f); } } } else { cin >> r; f = regal[r - 1]; if (f.z == 0 && f.d == 0) { z--; } else { if (f.d >= 0) { pos.erase(f); } else { neg.erase(f); } } } /* cout << "pos\n"; for (auto a: pos) { cout << a << "\n"; } cout << "neg\n"; for (auto a: neg) { cout << a << "\n"; } */ if (z > 0) { cout << "1\n"; } else { if (pos.size() != 0 && neg.size() != 0) { /* cout << *neg.begin() << " " << *--neg.end() << "\n"; cout << *pos.begin() << " " << *--pos.end() << "\n"; cout << ((*neg.begin()) <= (*--pos.end())) << ((*neg.begin()) >= (*pos.begin())) << ((*--neg.end()) <= (*--pos.end())) << ((*--neg.end()) >= (*pos.begin())) << "\n"; */ if (((*neg.begin()) <= (*--pos.end()) && (*neg.begin()) >= (*pos.begin())) || ((*--neg.end()) <= (*--pos.end()) && (*--neg.end()) >= (*pos.begin()))) { cout << "2\n"; } else { cout << "0\n"; } } else { cout << "0\n"; } } //cout << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...