답안 #256029

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256029 2020-08-02T08:37:10 Z 구재현(#5035) Mixture (BOI20_mixture) C++17
60 / 100
2000 ms 7544 KB
#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){ 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;
	for(int i=0; i<2; i++){
		s.emplace_back(cmp);
	}
	c = input();
	int q; scanf("%d",&q);
	char buf[69];
	while(q--){
		scanf("%s", buf);
		if(*buf == 'A'){
			a[++cnt] = input();
			int v = type(a[cnt]);
			if(v == -1) onecnt++;
			else{
				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(onecnt > 0) puts("1");
		else{
			auto j = s[1].begin(); 
			bool good = 0;
			for(auto &i : s[0]){
				while(j != s[1].end() && ccw(c, i, *j) > 0) j++;
				if(j != s[1].end() && ccw(c, i, *j) == 0){
					puts("2");
					good = 1;
					break;
				}
			}
			if(!good){
				puts(in_cvxh() ? "3" : "0");
			}
		}
		continue;
		for(auto &i : s[0]) printf("%d %d %d\n", i.x, i.y, i.d);
		puts("ok");
		for(auto &i : s[1]) printf("%d %d %d\n", i.x, i.y, i.d);
		puts("--");
	}
}

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:75: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:78:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s", buf);
   ~~~~~^~~~~~~~~~~
Mixture.cpp:88: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 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 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 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 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 1 ms 384 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 256 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 1 ms 256 KB Output is correct
32 Correct 1 ms 288 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 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 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 1 ms 384 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 256 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 1 ms 256 KB Output is correct
32 Correct 1 ms 288 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 256 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 4 ms 384 KB Output is correct
43 Correct 4 ms 384 KB Output is correct
44 Correct 4 ms 384 KB Output is correct
45 Correct 5 ms 512 KB Output is correct
46 Correct 6 ms 512 KB Output is correct
47 Correct 37 ms 632 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 4 ms 384 KB Output is correct
50 Correct 4 ms 384 KB Output is correct
51 Correct 64 ms 504 KB Output is correct
52 Correct 117 ms 760 KB Output is correct
53 Correct 6 ms 640 KB Output is correct
54 Correct 202 ms 632 KB Output is correct
55 Correct 3 ms 384 KB Output is correct
56 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 0 ms 256 KB Output is correct
16 Correct 0 ms 256 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 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 1 ms 384 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 256 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 1 ms 256 KB Output is correct
32 Correct 1 ms 288 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 256 KB Output is correct
38 Correct 2 ms 384 KB Output is correct
39 Correct 2 ms 384 KB Output is correct
40 Correct 3 ms 384 KB Output is correct
41 Correct 3 ms 384 KB Output is correct
42 Correct 4 ms 384 KB Output is correct
43 Correct 4 ms 384 KB Output is correct
44 Correct 4 ms 384 KB Output is correct
45 Correct 5 ms 512 KB Output is correct
46 Correct 6 ms 512 KB Output is correct
47 Correct 37 ms 632 KB Output is correct
48 Correct 3 ms 384 KB Output is correct
49 Correct 4 ms 384 KB Output is correct
50 Correct 4 ms 384 KB Output is correct
51 Correct 64 ms 504 KB Output is correct
52 Correct 117 ms 760 KB Output is correct
53 Correct 6 ms 640 KB Output is correct
54 Correct 202 ms 632 KB Output is correct
55 Correct 3 ms 384 KB Output is correct
56 Correct 3 ms 384 KB Output is correct
57 Correct 22 ms 516 KB Output is correct
58 Correct 56 ms 504 KB Output is correct
59 Correct 68 ms 596 KB Output is correct
60 Correct 7 ms 640 KB Output is correct
61 Correct 317 ms 1948 KB Output is correct
62 Correct 17 ms 2040 KB Output is correct
63 Correct 126 ms 7544 KB Output is correct
64 Execution timed out 2083 ms 4688 KB Time limit exceeded
65 Halted 0 ms 0 KB -