Submission #1086148

# Submission time Handle Problem Language Result Execution time Memory
1086148 2024-09-09T15:56:34 Z not_amir Mixture (BOI20_mixture) C++17
0 / 100
0 ms 604 KB
#include <bits/stdc++.h>
using namespace std;
 
#define pii pair<int, int>
#define PI M_PI - 1e-2
 
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int S, P, G, N;
    cin >> S >> P >> G >> N;
    G += S + P;
    multiset<pii> pts;
    multiset<long double> angles;
    vector<pair<pii, long double>> add;
    int ctrp = 0, ctrl = 0, ctrt = 1, t = 0;
    while(N--){
        char c;
        cin >> c;
        if(c == 'A'){
            int x, y, z, divide;
            pii fi;
            long double se;
            cin >> x >> y >> z;
            z += x + y;
            x = x * G - S * z;
            y = y * G - P * z;
            if(x == 0 && y == 0)
                ctrp++;
            else{
                divide = gcd(x, y);
                x?x /= divide:0; y?y /= divide:0;
                if(pts.find({x, y}) == pts.end() && pts.find({-x, -y}) != pts.end()) ctrl++;
                auto it2 = pts.insert(fi = {x, y});
                auto it = angles.insert(se = atan2l(y, x));
                if(angles.size() > 2){
                    if(it == angles.begin())
                        if(*angles.rbegin() - se > PI) ctrt=1;
                    else
                        if(se - *--it > PI) ctrt=1;
                    if(it == angles.end())
                        if(se - *angles.begin() > PI) ctrt=1;
                    else
                        if(*++it - se > PI) ctrt=1;
                }
                else
                    ctrt = 1;
                add.push_back({fi, se});
            }
        }
        else{
            int r, x, y;
            cin >> r;
            auto it2 = pts.find(add[r-1].first);
            auto it = angles.find(add[r-1].second);
            x = (*it2).first; y= (*it2).second;
            if(x == 0 && y == 0)
                ctrp--;
            else{
                pts.erase(it2);
                if(pts.find({x, y}) == pts.end() && pts.find({-x, -y}) != pts.end()) ctrl--;
                if(angles.size() > 2){
                    if(it == angles.begin())
                        if(*angles.rbegin() - *it > PI) ctrt=0;
                    else
                        if(*it - *--it > PI) ctrt=0;
                    if(it == angles.end())
                        if(*it - *angles.begin() > PI) ctrt=0;
                    else
                        if(*++it - *it > PI) ctrt=0;
                }
                else
                    ctrt = 1;
                angles.erase(it);
            }
        }
        if(ctrp)
            cout << "1\n";
        else if(ctrl)
            cout << "2\n";
        else if(!ctrt)
            cout << "3\n";
        else
            cout << "0\n";
    }
}

Compilation message

Mixture.cpp: In function 'int main()':
Mixture.cpp:36:23: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   36 |                     if(it == angles.begin())
      |                       ^
Mixture.cpp:40:23: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   40 |                     if(it == angles.end())
      |                       ^
Mixture.cpp:33:22: warning: variable 'it2' set but not used [-Wunused-but-set-variable]
   33 |                 auto it2 = pts.insert(fi = {x, y});
      |                      ^~~
Mixture.cpp:62:23: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   62 |                     if(it == angles.begin())
      |                       ^
Mixture.cpp:66:23: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   66 |                     if(it == angles.end())
      |                       ^
Mixture.cpp:15:39: warning: unused variable 't' [-Wunused-variable]
   15 |     int ctrp = 0, ctrl = 0, ctrt = 1, t = 0;
      |                                       ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 0 ms 604 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 0 ms 604 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 0 ms 604 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Runtime error 0 ms 604 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -