Submission #974430

# Submission time Handle Problem Language Result Execution time Memory
974430 2024-05-03T10:27:55 Z kl0989e Mixture (BOI20_mixture) C++17
100 / 100
125 ms 9808 KB
#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
 
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const ll MAX=1e5+10,P=1e9+7;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
 
ldb x,y,z;
ll n;
int s0=0;
int s1=0;
pair<ldb,ldb> btl[MAX];
const ldb PI=acos(-1.0),eps=1e-15;
struct cmp{
	bool operator()(const ldb& ax,const ldb& ay)const{
		return ax+eps<ay;
	}
};
multiset<ldb,cmp> agl;
 
 
bool eq(ldb a,ldb b) {
	return abs(a-b)<=eps;
}
 
ldb cal(ldb a,ldb b) {
	ldb ans=atan2(a,b);
//	cout<<a<<" "<<b<<" "<<ans<<" ang\n";
	if (ans<0) ans+=PI+PI;
	return ans;
}
 
ldb rev(ldb now) {
	if (now>PI) return now-PI;
	else return now+PI;
}
 
void isrt(ldb dx,ldb dy) {
	if (eq(dx,0) and eq(dy,0)) s0++;
	else {
		ldb now=cal(dx,dy);
//		cout<<now<<" "<<rev(now)<<" rev\n";
		if (agl.find(now)==agl.end() and agl.find(rev(now))!=agl.end()) s1++;
		agl.insert(now);
	}
}
 
void del(int id) {
	auto [dx,dy]=btl[id];
	if (eq(dx,0) and eq(dy,0)) s0--;
	else {
		ldb now=cal(dx,dy);
		agl.erase(agl.find(now));
		if (agl.find(now)==agl.end() and agl.find(rev(now))!=agl.end()) s1--;
	}
}
 
int main() {
	speed;
//	cout<<PI<<"\n"<<flush;
	cin>>x>>y>>z;
	ldb tsum=x+y+z;
	x/=tsum;
	y/=tsum;
//	cout<<x<<" "<<y<<" xy\n";
	cin>>n;
	int now=1;
	for (int i=1;i<=n;i++) {
		char c;
		cin>>c;
		if (c=='A') {
			ldb tx,ty,tz;
			cin>>tx>>ty>>tz;
			ldb sum=tx+ty+tz;
			tx/=sum;
			ty/=sum;
//			cout<<now<<" "<<tx<<" "<<ty<<" xy1\n";
			tx-=x;
			ty-=y;
//			cout<<now<<" "<<tx<<" "<<ty<<" xy2\n";
			btl[now++]={tx,ty};
			isrt(tx,ty);
		} else {
			int id;
			cin>>id;
			del(id);
		}
//		for (auto k:agl) cout<<k<<" ";
//		cout<<" st\n";
//		cout<<s1<<" s1\n";
		if (s0>0) cout<<"1\n";
		else if (s1>0) cout<<"2\n";
		else if (agl.size()>=3) {
			bool yes=true;
			yes&=((PI+PI-*agl.rbegin()+*agl.begin())<PI);
			auto it=agl.lower_bound(PI);
			if (it==agl.begin()) yes=false;
			else {
				yes&=((*it-*prev(it))<PI);
			}
			if (yes) cout<<"3\n";
			else cout<<"0\n";
		} else {
			cout<<"0\n";
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 3 ms 604 KB Output is correct
48 Correct 2 ms 348 KB Output is correct
49 Correct 2 ms 348 KB Output is correct
50 Correct 2 ms 348 KB Output is correct
51 Correct 4 ms 600 KB Output is correct
52 Correct 4 ms 860 KB Output is correct
53 Correct 5 ms 860 KB Output is correct
54 Correct 5 ms 856 KB Output is correct
55 Correct 3 ms 600 KB Output is correct
56 Correct 3 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 3 ms 604 KB Output is correct
48 Correct 2 ms 348 KB Output is correct
49 Correct 2 ms 348 KB Output is correct
50 Correct 2 ms 348 KB Output is correct
51 Correct 4 ms 600 KB Output is correct
52 Correct 4 ms 860 KB Output is correct
53 Correct 5 ms 860 KB Output is correct
54 Correct 5 ms 856 KB Output is correct
55 Correct 3 ms 600 KB Output is correct
56 Correct 3 ms 604 KB Output is correct
57 Correct 4 ms 604 KB Output is correct
58 Correct 7 ms 600 KB Output is correct
59 Correct 6 ms 604 KB Output is correct
60 Correct 5 ms 760 KB Output is correct
61 Correct 16 ms 4060 KB Output is correct
62 Correct 18 ms 3932 KB Output is correct
63 Correct 104 ms 9040 KB Output is correct
64 Correct 106 ms 9084 KB Output is correct
65 Correct 100 ms 5716 KB Output is correct
66 Correct 101 ms 5496 KB Output is correct
67 Correct 0 ms 348 KB Output is correct
68 Correct 0 ms 600 KB Output is correct
69 Correct 125 ms 9808 KB Output is correct
70 Correct 121 ms 7764 KB Output is correct
71 Correct 107 ms 7760 KB Output is correct
72 Correct 104 ms 9204 KB Output is correct
73 Correct 114 ms 9136 KB Output is correct