Submission #897601

#TimeUsernameProblemLanguageResultExecution timeMemory
897601pccMixture (BOI20_mixture)C++14
0 / 100
1 ms2652 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll,ll> #define pii pair<int,int> #define fs first #define sc second #define tlll tuple<ll,ll,ll> struct point{ ll x,y,z; point(){x = y = z = 0;} point(int a,int b,int c){x = a,y = b,z = c;} point operator+(point b)const{return point(x+b.x,y+b.y,z+b.z);} point operator-(point b)const{return point(x-b.x,y-b.y,z-b.z);} ll operator*(point b)const{return x*b.x+y*b.y+z*b.z;} point operator^(point b)const{return point(y*b.z-z*b.y,z*b.x-x*b.z,x*b.y-y*b.x);} bool operator<(point b)const{return x== b.x?y == b.y?z<b.z:y<b.y:x<b.x;} bool operator==(point b)const{return x==b.x&&y==b.y&&z==b.z;} bool operator!=(point b)const{return !((*this) == b);} }; const int mxn = 1e5+10; ll Q; point arr[mxn]; int pt = 0; point tar; int nowans; ll one,two; map<point,ll> mp,normal; inline point trans(point tmp){ ll G = 0; if(tmp.x)G = (G?__gcd(G,abs(tmp.x)):abs(tmp.x)); if(tmp.y)G = (G?__gcd(G,abs(tmp.y)):abs(tmp.y)); if(tmp.z)G = (G?__gcd(G,abs(tmp.z)):abs(tmp.z)); tmp.x/=G,tmp.y/=G,tmp.z/=G; if(tmp.x<0||(tmp.x == 0&&tmp.y<0)||(tmp.x == 0&&tmp.y == 0&&tmp.z<0)){ tmp.x = -tmp.x; tmp.y = -tmp.y; tmp.z = -tmp.z; } return tmp; } inline void add(point now){ mp[now]++; if(now == tar){ one++; return; } auto tmp = (now^tar); tmp = trans(tmp); normal[tmp]++; two += normal[tmp]-mp[now]; return; } inline void del(point now){ assert(mp.find(now) != mp.end()); if(now == tar){ one--; mp[now]--; return; } auto tmp = (now^tar); tmp = trans(tmp); two -= normal[tmp]-mp[now]; normal[tmp] --; mp[now]--; if(!mp[now])mp.erase(now); return; } inline int getans(){ assert(one>=0&&two>=0); if(one)return 1; else if(two)return 2; else if(normal.size()>1&&mp.size()>2)return 3; else return 0; } int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>tar.x>>tar.y>>tar.z; tar = trans(tar); cin>>Q; while(Q--){ char tp; cin>>tp; if(tp == 'A'){ pt++; cin>>arr[pt].x>>arr[pt].y>>arr[pt].z; arr[pt] = trans(arr[pt]); add(arr[pt]); } else{ int id; cin>>id; del(arr[id]); } cout<<getans()<<'\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...