Submission #1185480

#TimeUsernameProblemLanguageResultExecution timeMemory
1185480steveonalexMixture (BOI20_mixture)C++20
Compilation error
0 ms0 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; } ll getArea(pair<ll, ll> a, pair<ll, ll> b, pair<ll, ll> c){ return a.first * (b.second - c.second) + b.first * (c.second - a.second) + c.first * (a.second - b.second); } struct compareccw{ bool operator () (pair<ll, ll> a, pair<ll, ll> b){ return getArea(a, b, make_pair(0, 0)) > 0; } }; 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; } bool is_in_quadrant(pair<ll, ll> p, int x){ if (x == 0){ return p.first >= 0 && p.second >= 0; } else if (x == 1) { return p.first >= 0 && p.second <= 0; } else if (x == 2){ return p.first <= 0 && p.second <= 0; } else { return p.first <= 0 && p.second >= 0; } } multiset<pair<ll, ll>, compareccw> S[4]; bool check_3(){ vector<pair<ll, ll>> a; for(int x = 0; x < 4; ++x) if (S[x].size()){ a.push_back(*S[x].begin()); a.push_back(*S[x].rbegin()); } int mask = 0; 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 if (sum < 0) 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 if (sum < 0) mask |= 8; } } return ((mask & 3) == 3 || (mask & 12) == 12); } 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; 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 x = 0; x < 4; ++x) if (is_in_quadrant(vec, x)) S[x].insert(vec); } } 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 x = 0; x < 4; ++x) if (is_in_quadrant(vec, x)) S[x].erase(S[x].find(vec)); } } if (zero_cnt) cout << 1 << "\n"; else if (pair_cnt) cout << 2 << "\n"; else if (check_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; }

Compilation message (stderr)

In file included from /usr/include/c++/11/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:81,
                 from Mixture.cpp:1:
/usr/include/c++/11/bits/stl_tree.h: In instantiation of 'static const _Key& std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_S_key(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type) [with _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = compareccw; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Const_Link_type = const std::_Rb_tree_node<std::pair<long long int, long long int> >*]':
/usr/include/c++/11/bits/stl_tree.h:2102:44:   required from 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_equal_pos(const key_type&) [with _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = compareccw; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::key_type = std::pair<long long int, long long int>]'
/usr/include/c++/11/bits/stl_tree.h:2151:4:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_equal(_Arg&&) [with _Arg = const std::pair<long long int, long long int>&; _Key = std::pair<long long int, long long int>; _Val = std::pair<long long int, long long int>; _KeyOfValue = std::_Identity<std::pair<long long int, long long int> >; _Compare = compareccw; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, compareccw, std::allocator<std::pair<long long int, long long int> > >::iterator]'
/usr/include/c++/11/bits/stl_multiset.h:503:36:   required from 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = std::pair<long long int, long long int>; _Compare = compareccw; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::multiset<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, compareccw, std::allocator<std::pair<long long int, long long int> > >::const_iterator; std::multiset<_Key, _Compare, _Alloc>::value_type = std::pair<long long int, long long int>]'
Mixture.cpp:146:32:   required from here
/usr/include/c++/11/bits/stl_tree.h:770:15: error: static assertion failed: comparison object must be invocable as const
  770 |               is_invocable_v<const _Compare&, const _Key&, const _Key&>,
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/bits/stl_tree.h:770:15: note: 'std::is_invocable_v<const compareccw&, const std::pair<long long int, long long int>&, const std::pair<long long int, long long int>&>' evaluates to false