Submission #1262260

#TimeUsernameProblemLanguageResultExecution timeMemory
1262260ewirlanMixture (BOI20_mixture)C++20
100 / 100
165 ms33344 KiB
// #ifndef __SIZEOF_INT128__ #define __SIZEOF_INT128__ #endif #pragma GCC optimize("Ofast") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace chrono; using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; #define rep(i, p, k) for(int i(p); i < (k); ++i) #define per(i, p, k) for(int i(p); i > (k); --i) #define sz(x) (int)(x).size() #define sc static_cast typedef long long ll; typedef long double ld; typedef unsigned int uint; typedef unsigned long long ull; //#define int ll template <typename T = int> using par = std::pair <T, T>; #define fi first #define se second #define test int _number_of_tests(in()); while(_number_of_tests--) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define pb emplace_back struct Timer { string name{""}; time_point<high_resolution_clock> end, start{high_resolution_clock::now()}; duration<float, std::milli> dur; Timer() = default; Timer(string nm): name(nm) {} ~Timer() { end = high_resolution_clock::now(); dur= end - start; cout << "@" << name << "> " << dur.count() << " ms" << '\n'; } }; template <typename T = int> inline T in() { static T x; std::cin >> x; return x; } std::string yn(bool b) { if(b) return "YES\n"; else return "NO\n"; } template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par); template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector <T>& wek) { for(const auto& i : wek)out << i << ' '; return out; } template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par) { out << '{'<<par.first<<", "<<par.second<<"}"; return out; } #define show(x) cerr << #x << " = " << x << '\n'; typedef long double lll; struct fra { lll a, b; fra(lll x, lll y) : a(x), b(y){ if(b < 0 || (b == 0 && a < 0)){a=-a;b=-b;} } fra(lll x) : a(x), b(1){} friend fra operator*(fra x, fra y){return {x.a*y.a, x.b*y.b};} friend fra operator/(fra x, fra y){return {x.a*y.b, x.b*y.a};} friend fra operator+(fra x, fra y){return {x.a*y.b+ x.b*y.a, x.b*y.b};} friend fra operator-(fra x, fra y){return {x.a*y.b- x.b*y.a, x.b*y.b};} friend bool operator<(fra x, fra y){return x.a*lll(y.b) < x.b*lll(y.a);} friend bool operator==(fra x, fra y){return x.a*lll(y.b) == x.b*lll(y.a);} friend ostream& operator<<(ostream& out, fra f){return out << ll(f.a) << '/' << ll(f.b);} }; struct pkt { fra x, y; pkt(fra a, fra b) : x(a), y(b) {} friend fra operator*(pkt a, pkt b){return a.x*b.y - b.x*a.y;} bool z(){return y < 0 || (y == 0 && x < 0);} friend bool operator<(pkt a, pkt b){ if(a.z() != b.z())return a.z() < b.z(); return a*b < 0; } friend ostream& operator<<(ostream& out, pkt f){return out << '('<<(f.x) << ',' << (f.y)<<')';} }; std::int32_t main() { std::cout.tie(nullptr); //for luck std::cin.tie(nullptr); std::ios_base::sync_with_stdio(0); bool s02(0), s12(0); int s[3]; cin >> s[0] >> s[1] >> s[2]; if(!s[2]){ if(s[1]){ s12 = 1; swap(s[1], s[2]); } else{ s02 = 1; swap(s[0], s[2]); } } vector <pkt> v; v.pb(fra(s[0])/s[2], fra(s[1])/s[2]); int c1(0); ll c2(0); int c4(0); int rn(0); multiset <pkt> S; map <pair <fra, bool>, int> M; auto wst = [&](auto p){return prev(p == S.begin() ? S.end() : p);}; auto wpr = [&](auto p){return next(p) == S.end() ? S.begin() : next(p);}; test{ if(in<char>() == 'A'){ int t[3]; cin >> t[0] >> t[1] >> t[2]; if(s12)swap(t[1],t[2]); if(s02)swap(t[0],t[2]); if(t[2])v.pb(fra(t[0])/t[2]-v[0].x,fra(t[1])/t[2]-v[0].y); else v.pb(t[0],t[1]); auto p(v.back()); // cerr << p << '\n'; if(p.x == 0 && p.y == 0)++c1; else{ auto g(S.insert(p)); if(S.size() > 2)c4 -= 0 < *wst(g)**wpr(g); if(S.size() > 1){ c4 += 0 < *g**wpr(g); c4 += 0 < *wst(g)**g; } if(++M[{p.x/p.y, p.z()}] == 1)++rn; c2 += M[{p.x/p.y, !p.z()}]; } } else{ auto p(v[in()]); if(p.x == 0 && p.y == 0)--c1; else{ auto g(S.find(p)); if(S.size() > 2)c4 += 0 < *wst(g)**wpr(g); if(S.size() > 1){ c4 -= 0 < *g**wpr(g); c4 -= 0 < *wst(g)**g; } S.erase(g); if(!--M[{p.x/p.y, p.z()}])--rn; c2 -= M[{p.x/p.y, !p.z()}]; } } // cerr << c1 << ' ' << c2 << ' ' << c4 << ' '; // for(auto i: S)cerr << i << ' '; // cerr << '\n'; cout << (c1 ? 1 : c2 ? 2 : (c4 || S.size() < 3 || rn == 1) ? 0 : 3) << '\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...