Submission #1086056

# Submission time Handle Problem Language Result Execution time Memory
1086056 2024-09-09T12:19:49 Z not_amir Mixture (BOI20_mixture) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
using namespace std::numbers;

#define pii pair<int, int>

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int S, P, G, N;
    cin >> S >> P >> G >> N;
    G += S + P;
    set<pii> pts;
    set<double> angles;
    vector<pair<set<pii>::iterator, set<double>::iterator>> add;
    int ctrl = 0, ctrt = 0, t = 0;
    while(N--){
        char c;
        cin >> c;
        if(c == 'A'){
            int x, y, z, divide;
            cin >> x >> y >> z;
            z += x + y;
            x = x * G - S * z;
            y = y * G - P * z;
            divide = gcd(x, y);
            pii v = {x?x / divide:0, y?y / divide:0};
            if(pts.find({-v.first, -v.second}) != pts.end()) ctrl++;
            auto it2 = pts.insert(v).first;
            auto it = angles.insert(atan2(v.second, v.first)).first;
            if(it == angles.begin())
                if(*angles.rbegin() - *it > M_PI) ctrt=1;
            else
                if(*it - *--it > M_PI) ctrt=1;
            if(it == angles.end())
                if(*it - *angles.begin() > M_PI) ctrt=1;
            else
                if(*++it - *it > M_PI) ctrt=1;
            add.push_back({it2, it});
        }
        else{
            int r, x, y;
            cin >> r;
            auto it2 = add[r-1].first;
            auto it = add[r-1].second;
            if(pts.find({-(*it2).first, -(*it2).second}) != pts.end()) ctrl--;
            pts.erase(it2);
            if(it == angles.begin())
                if(*angles.rbegin() - *it > M_PI) ctrt=0;
            else
                if(*it - *--it > M_PI) ctrt=0;
            if(it == angles.end())
                if(*it - *angles.begin() > M_PI) ctrt=0;
            else
                if(*++it - *it > M_PI) ctrt=0;
            angles.erase(it);
        }
        if(pts.find({0, 0}) != pts.end())
            cout << "1 ";
        else if(ctrl)
            cout << "2 ";
        else if(ctrt)
            cout << "3 ";
        else
            cout << "0 ";
    }
}

Compilation message

Mixture.cpp:3:22: error: 'numbers' is not a namespace-name
    3 | using namespace std::numbers;
      |                      ^~~~~~~
Mixture.cpp: In function 'int main()':
Mixture.cpp:25:22: error: 'gcd' was not declared in this scope
   25 |             divide = gcd(x, y);
      |                      ^~~
Mixture.cpp:30:15: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   30 |             if(it == angles.begin())
      |               ^
Mixture.cpp:34:15: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   34 |             if(it == angles.end())
      |               ^
Mixture.cpp:47:15: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   47 |             if(it == angles.begin())
      |               ^
Mixture.cpp:51:15: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   51 |             if(it == angles.end())
      |               ^
Mixture.cpp:41:20: warning: unused variable 'x' [-Wunused-variable]
   41 |             int r, x, y;
      |                    ^
Mixture.cpp:41:23: warning: unused variable 'y' [-Wunused-variable]
   41 |             int r, x, y;
      |                       ^
Mixture.cpp:15:29: warning: unused variable 't' [-Wunused-variable]
   15 |     int ctrl = 0, ctrt = 0, t = 0;
      |                             ^