#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 100005;
inline int frcmp(int x1, int d1, int x2, int d2){
lint p = 1ll * x2 * d1 - 1ll * x1 * d2;
if(p > 0) return 1;
if(p < 0) return -1;
return 0;
}
struct pnt{
int x, y, d;
bool operator<(const pnt &b)const{
int t = frcmp(x, d, b.x, b.d);
if(t != 0) return t > 0;
return frcmp(y, d, b.y, b.d) > 0;
}
bool operator==(const pnt &p)const{
return x == p.x && y == p.y && d == p.d;
}
bool operator>(const pnt &b)const{
return b < *this;
}
};
pnt input(){
int x, y, z; scanf("%d %d %d",&x,&y,&z);
int g = gcd(x, gcd(y, z));
x /= g; y /= g; z /= g;
return (pnt){x, y, x + y + z};
}
inline int ccw(pnt p1, pnt p2, pnt p3){
lint lhs = 1ll * p1.d * p2.x * p3.y - 1ll * p1.x * p2.d * p3.y - 1ll * p1.y * p2.x * p3.d;
lint rhs = 1ll * p1.d * p2.y * p3.x - 1ll * p1.x * p2.y * p3.d - 1ll * p1.y * p2.d * p3.x;
if(lhs > rhs) return 1;
if(lhs < rhs) return -1;
return 0;
}
pnt c, a[MAXN];
bool mark[MAXN];
int cnt;
int type(pnt p){
if(c == p) return -1;
if(c < p) return 0;
return 1;
}
auto cmp = [](pnt a, pnt b){
if(type(a) == type(b)){
return ccw(c, a, b) > 0;
}
return ccw(c, a, b) < 0;
};
vector<multiset<pnt, decltype(cmp)>> s;
bool in_cvxh(){
if(sz(s[1]) == 0 || sz(s[0]) == 0) return 0;
if(ccw(c, *s[0].rbegin(), *s[1].begin()) < 0) return 0;
if(ccw(c, *s[1].rbegin(), *s[0].begin()) < 0) return 0;
return 1;
}
int main(){
int onecnt = 0;
int collapse = 0;
for(int i=0; i<2; i++){
s.emplace_back(cmp);
}
c = input();
int q; scanf("%d",&q);
char buf[69];
while(q--){
auto fresh = [&](int v, pnt p){
auto it = s[v].lower_bound(p);
if(it != s[v].end() && ccw(c, p, *it) == 0) return false;
return true;
};
scanf("%s", buf);
if(*buf == 'A'){
a[++cnt] = input();
int v = type(a[cnt]);
if(v == -1) onecnt++;
else{
if(fresh(v, a[cnt])){
auto it = s[v^1].lower_bound(a[cnt]);
if(it != s[v^1].end() && ccw(c, *it, a[cnt]) == 0) collapse++;
}
s[v].insert(a[cnt]);
}
}
else{
int x; scanf("%d",&x);
mark[x] = 1;
int v = type(a[x]);
if(v == -1) onecnt--;
else{
s[v].erase(s[v].find(a[x]));
if(fresh(v, a[x])){
auto it = s[v^1].lower_bound(a[x]);
if(it != s[v^1].end() && ccw(c, *it, a[x]) == 0) collapse--;
}
}
}
if(onecnt > 0) puts("1");
else if(collapse > 0) puts("2");
else puts(in_cvxh() ? "3" : "0");
}
}
Compilation message
Mixture.cpp: In function 'pnt input()':
Mixture.cpp:33:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
int x, y, z; scanf("%d %d %d",&x,&y,&z);
~~~~~^~~~~~~~~~~~~~~~~~~~~
Mixture.cpp: In function 'int main()':
Mixture.cpp:82:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
int q; scanf("%d",&q);
~~~~~^~~~~~~~~
Mixture.cpp:90:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%s", buf);
~~~~~^~~~~~~~~~~
Mixture.cpp:104:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
int x; scanf("%d",&x);
~~~~~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
256 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
256 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
256 KB |
Output is correct |
21 |
Correct |
0 ms |
256 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
0 ms |
256 KB |
Output is correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
33 |
Correct |
1 ms |
256 KB |
Output is correct |
34 |
Correct |
1 ms |
384 KB |
Output is correct |
35 |
Correct |
1 ms |
384 KB |
Output is correct |
36 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
256 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
256 KB |
Output is correct |
21 |
Correct |
0 ms |
256 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
0 ms |
256 KB |
Output is correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
33 |
Correct |
1 ms |
256 KB |
Output is correct |
34 |
Correct |
1 ms |
384 KB |
Output is correct |
35 |
Correct |
1 ms |
384 KB |
Output is correct |
36 |
Correct |
1 ms |
384 KB |
Output is correct |
37 |
Correct |
1 ms |
384 KB |
Output is correct |
38 |
Correct |
1 ms |
384 KB |
Output is correct |
39 |
Correct |
1 ms |
384 KB |
Output is correct |
40 |
Correct |
1 ms |
384 KB |
Output is correct |
41 |
Correct |
1 ms |
384 KB |
Output is correct |
42 |
Correct |
1 ms |
384 KB |
Output is correct |
43 |
Correct |
2 ms |
384 KB |
Output is correct |
44 |
Correct |
2 ms |
384 KB |
Output is correct |
45 |
Correct |
1 ms |
384 KB |
Output is correct |
46 |
Correct |
4 ms |
512 KB |
Output is correct |
47 |
Correct |
5 ms |
512 KB |
Output is correct |
48 |
Correct |
2 ms |
384 KB |
Output is correct |
49 |
Correct |
3 ms |
384 KB |
Output is correct |
50 |
Correct |
3 ms |
384 KB |
Output is correct |
51 |
Correct |
6 ms |
512 KB |
Output is correct |
52 |
Correct |
6 ms |
640 KB |
Output is correct |
53 |
Correct |
6 ms |
640 KB |
Output is correct |
54 |
Correct |
6 ms |
640 KB |
Output is correct |
55 |
Correct |
5 ms |
512 KB |
Output is correct |
56 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
0 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
0 ms |
256 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
0 ms |
384 KB |
Output is correct |
15 |
Correct |
0 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
256 KB |
Output is correct |
19 |
Correct |
0 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
256 KB |
Output is correct |
21 |
Correct |
0 ms |
256 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
0 ms |
256 KB |
Output is correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
33 |
Correct |
1 ms |
256 KB |
Output is correct |
34 |
Correct |
1 ms |
384 KB |
Output is correct |
35 |
Correct |
1 ms |
384 KB |
Output is correct |
36 |
Correct |
1 ms |
384 KB |
Output is correct |
37 |
Correct |
1 ms |
384 KB |
Output is correct |
38 |
Correct |
1 ms |
384 KB |
Output is correct |
39 |
Correct |
1 ms |
384 KB |
Output is correct |
40 |
Correct |
1 ms |
384 KB |
Output is correct |
41 |
Correct |
1 ms |
384 KB |
Output is correct |
42 |
Correct |
1 ms |
384 KB |
Output is correct |
43 |
Correct |
2 ms |
384 KB |
Output is correct |
44 |
Correct |
2 ms |
384 KB |
Output is correct |
45 |
Correct |
1 ms |
384 KB |
Output is correct |
46 |
Correct |
4 ms |
512 KB |
Output is correct |
47 |
Correct |
5 ms |
512 KB |
Output is correct |
48 |
Correct |
2 ms |
384 KB |
Output is correct |
49 |
Correct |
3 ms |
384 KB |
Output is correct |
50 |
Correct |
3 ms |
384 KB |
Output is correct |
51 |
Correct |
6 ms |
512 KB |
Output is correct |
52 |
Correct |
6 ms |
640 KB |
Output is correct |
53 |
Correct |
6 ms |
640 KB |
Output is correct |
54 |
Correct |
6 ms |
640 KB |
Output is correct |
55 |
Correct |
5 ms |
512 KB |
Output is correct |
56 |
Correct |
5 ms |
384 KB |
Output is correct |
57 |
Correct |
8 ms |
512 KB |
Output is correct |
58 |
Correct |
8 ms |
512 KB |
Output is correct |
59 |
Correct |
8 ms |
512 KB |
Output is correct |
60 |
Correct |
8 ms |
512 KB |
Output is correct |
61 |
Correct |
29 ms |
1528 KB |
Output is correct |
62 |
Correct |
31 ms |
1536 KB |
Output is correct |
63 |
Correct |
154 ms |
5752 KB |
Output is correct |
64 |
Correct |
186 ms |
5752 KB |
Output is correct |
65 |
Correct |
156 ms |
2552 KB |
Output is correct |
66 |
Correct |
148 ms |
2552 KB |
Output is correct |
67 |
Correct |
0 ms |
256 KB |
Output is correct |
68 |
Correct |
0 ms |
384 KB |
Output is correct |
69 |
Correct |
189 ms |
6392 KB |
Output is correct |
70 |
Correct |
168 ms |
4984 KB |
Output is correct |
71 |
Correct |
158 ms |
4984 KB |
Output is correct |
72 |
Correct |
187 ms |
5624 KB |
Output is correct |
73 |
Correct |
173 ms |
5788 KB |
Output is correct |