Submission #873207

# Submission time Handle Problem Language Result Execution time Memory
873207 2023-11-14T15:50:55 Z Pacybwoah Mixture (BOI20_mixture) C++17
0 / 100
1 ms 504 KB
#include<iostream>
#include<vector>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
struct point{
    ll x,y,z;
    point(ll _x,ll _y,ll _z){
        x=_x;
        y=_y;
        z=_z;
    }
};
bool eq(point a,point b){
    return a.x==b.x&&a.y==b.y&&a.z==b.z;
}
point cross(point a,point b){
    point tmp(a.y*b.z-a.z*b.y,a.z*b.x-b.z*a.x,a.x*b.y-a.y*b.x);
    //cout<<tmp.x<<" "<<tmp.y<<" "<<tmp.z;
    ll g=gcd(tmp.x,tmp.y);
    g=gcd(g,tmp.z);
    if(g!=0){
        tmp.x/=g;
        tmp.y/=g;
        tmp.z/=g;
    }
    if(tmp.x<0){
        tmp.x=-tmp.x;
        tmp.y=-tmp.y;
        tmp.z=-tmp.z;
    }
    return tmp;
}
bool operator<(const point& a,const point& b){
    if(a.x==b.x){
        if(a.y==b.y) return a.z<b.z;
        return a.y<b.y;
    }
    return a.x<b.x;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    point tar(0,0,0);
    cin>>tar.x>>tar.y>>tar.z;
    char op;
    int q;
    cin>>q;
    map<point,int> m;
    vector<point> vec(q+1,point(0,0,0));
    int cur=1,cnt=0,cntcnt=0,nonzero=0;
    point zero(0,0,0);
    for(int i=0;i<q;i++){
        cin>>op;
        if(op=='A'){
            cin>>vec[cur].x>>vec[cur].y>>vec[cur].z;
            cur++;
            point res=cross(tar,vec[cur-1]);
            if(eq(res,zero)) cnt++;
            if(m.count(res)==0){
                m[res]=1;
                nonzero++;
            }
            else{
                if(m[res]==1){
                    cntcnt++;
                }
                m[res]++;
            }
        }
        else{
            int num;
            cin>>num;
            point res=cross(tar,vec[num]);
            if(eq(res,zero)) cnt--;
            if(m[res]==2){
                cntcnt--;
            }
            if(m[res]==1){
                nonzero--;
            }
            m[res]--;
        }
        if(cnt>0){
            cout<<"1\n";
        }
        else if(cntcnt>0){
            cout<<"2\n";
        }
        else if(nonzero>2){
            cout<<"3\n";
        }
        else cout<<"0\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -