Submission #974420

#TimeUsernameProblemLanguageResultExecution timeMemory
974420kl0989eMixture (BOI20_mixture)C++17
13 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pb push_back #define vi vector<int> #define pi pair<int, int> #define all(x) (x).begin(),(x).end() const long double PI=acos(-1); struct cmp{ bool operator()(const long double& a,const long double& b)const{ return a+1e-15<b; } }; int main() { ios::sync_with_stdio(0); cin.tie(0); int X,Y,Z; cin >> X >> Y >> Z; long double yy=1.0*Y/(X+Y+Z),xx=1.0*X/(X+Y+Z); int cnt1=0,cnt2=0; int n; cin >> n; vector<vi> points; multiset<long double,cmp> angles; char c; int x,y,z; for (int i=0; i<n; i++) { cin >> c; if (c=='A') { cin >> x >> y >> z; points.pb({x,y,z}); if (1ll*X*(x+y+z)==1ll*x*(X+Y+Z) && 1ll*Y*(x+y+z)==1ll*y*(X+Y+Z)) { cnt1++; } long double ang=atan2(1.0*y/(x+y+z)-yy,1.0*x/(x+y+z)-xx); //cout << "ang: " << i << ' ' << ang << ' ' << (1.0*y/(x+y+z))-yy << ' ' << (1.0*x/(x+y+z))-xx << '\n'; //cout << 1.0*y/(x+y+z) << ' ' << 1.0*x/(x+y+z) << ' ' << yy << ' ' << xx << '\n'; angles.emplace(ang); if (ang>0) { ang-=PI; } else { ang+=PI; } cnt2+=angles.count(ang); //cout << "CNT: " << angles.count(ang) << ' ' << cnt2 << ' ' << ang << '\n'; } else { cin >> x; y=points[--x][1]; z=points[x][2]; x=points[x][0]; if (1ll*X*(x+y+z)==1ll*x*(X+Y+Z) && 1ll*Y*(x+y+z)==1ll*y*(X+Y+Z)) { cnt1--; } long double ang=atan2(1.0*y/(x+y+z)-yy,1.0*x/(x+y+z)-xx); angles.extract(ang); if (ang>0) { ang-=PI; } else { ang+=PI; } cnt2-=angles.count(ang); } if (cnt1) { cout << "1\n"; } else if (cnt2) { cout << "2\n"; } else { bool ok=1; if (angles.size()<3) { ok=0; } else if ((*angles.rbegin()-*angles.begin())<PI) { ok=0; } else { auto it=angles.lower_bound(0); if (it==angles.begin()) { ok=0; } else if ((*it-*prev(it)>PI)) { ok=0; } else if (it!=--angles.end() && *next(it)-*it>PI) { ok=0; } } if (ok) { cout << "3\n"; } else { cout << "0\n"; } } /*cout << "I: " << i << ' '; for (auto it=angles.begin(); it!=angles.end(); it++) { cout << *it << ' '; } cout << '\n'; cout << "cnt: " << cnt2 << '\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...