답안 #284125

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
284125 2020-08-26T21:59:06 Z duality Mixture (BOI20_mixture) C++11
100 / 100
167 ms 8288 KB
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int Sf,Pf,Gf;
int S[100000],P[100000],G[100000];
struct point { LLI x,y; };
class comp {
    public:
        bool operator()(point a,point b) const {
            return (long double) a.x*b.y > (long double) a.y*b.x;
        }
};
point angle(int S,int P,int G) {
    return (point){(LLI) S*(Sf+Pf+Gf)-(LLI) Sf*(S+P+G),(LLI) P*(Sf+Pf+Gf)-(LLI) Pf*(S+P+G)};
}
int quad(point p) {
    if ((p.x == 0) && (p.y == 0)) return -1;
    else if ((p.x > 0) && (p.y >= 0)) return 0;
    else if ((p.x <= 0) && (p.y > 0)) return 1;
    else if ((p.x < 0) && (p.y <= 0)) return 2;
    else return 3;
}
multiset<point,comp> SS[4];
int main() {
    int i;
    int N;
    int b = 0,r;
    char c;
    int o = 0,oo = 0;
    scanf("%d %d %d %d",&Sf,&Pf,&Gf,&N);
    for (i = 0; i < N; i++) {
        scanf(" %c",&c);
        if (c == 'A') {
            scanf("%d %d %d",&S[b],&P[b],&G[b]);
            point d = angle(S[b],P[b],G[b]);
            b++;
            int q = quad(d);
            if (q == -1) oo++;
            else {
                if (SS[q].find(d) == SS[q].end()) {
                    d.x *= -1,d.y *= -1;
                    if (SS[q^2].find(d) != SS[q^2].end()) o++;
                    d.x *= -1,d.y *= -1;
                }
                SS[q].insert(d);
            }
        }
        else {
            scanf("%d",&r),r--;
            point d = angle(S[r],P[r],G[r]);
            int q = quad(d);
            if (q == -1) oo--;
            else {
                SS[q].erase(SS[q].find(d));
                if (SS[q].find(d) == SS[q].end()) {
                    d.x *= -1,d.y *= -1;
                    if (SS[q^2].find(d) != SS[q^2].end()) o--;
                }
            }
        }
        if (oo > 0) printf("1\n");
        else if (o > 0) printf("2\n");
        else {
            int q;
            for (q = 0; q < 4; q++) {
                if (SS[q].empty()) {
                    if (SS[(q+1) & 3].empty() || SS[(q+3) & 3].empty()) break;
                    else if (comp()(*SS[(q+1) & 3].begin(),*SS[(q+3) & 3].rbegin())) break;
                }
            }
            printf((q < 4) ? "0\n":"3\n");
        }
    }

    return 0;
}

Compilation message

Mixture.cpp: In function 'int main()':
Mixture.cpp:84:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   84 |     scanf("%d %d %d %d",&Sf,&Pf,&Gf,&N);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mixture.cpp:86:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   86 |         scanf(" %c",&c);
      |         ~~~~~^~~~~~~~~~
Mixture.cpp:88:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   88 |             scanf("%d %d %d",&S[b],&P[b],&G[b]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mixture.cpp:103:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  103 |             scanf("%d",&r),r--;
      |             ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 360 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 360 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 2 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 404 KB Output is correct
28 Correct 1 ms 360 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 384 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 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 360 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 2 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 404 KB Output is correct
28 Correct 1 ms 360 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 384 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 360 KB Output is correct
41 Correct 1 ms 384 KB Output is correct
42 Correct 1 ms 384 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 1 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 3 ms 512 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 5 ms 616 KB Output is correct
52 Correct 5 ms 776 KB Output is correct
53 Correct 6 ms 768 KB Output is correct
54 Correct 5 ms 768 KB Output is correct
55 Correct 3 ms 512 KB Output is correct
56 Correct 3 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 360 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 2 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 404 KB Output is correct
28 Correct 1 ms 360 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 384 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 360 KB Output is correct
41 Correct 1 ms 384 KB Output is correct
42 Correct 1 ms 384 KB Output is correct
43 Correct 1 ms 384 KB Output is correct
44 Correct 1 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 3 ms 512 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 3 ms 384 KB Output is correct
51 Correct 5 ms 616 KB Output is correct
52 Correct 5 ms 776 KB Output is correct
53 Correct 6 ms 768 KB Output is correct
54 Correct 5 ms 768 KB Output is correct
55 Correct 3 ms 512 KB Output is correct
56 Correct 3 ms 512 KB Output is correct
57 Correct 5 ms 640 KB Output is correct
58 Correct 6 ms 640 KB Output is correct
59 Correct 8 ms 672 KB Output is correct
60 Correct 6 ms 548 KB Output is correct
61 Correct 17 ms 2048 KB Output is correct
62 Correct 19 ms 2048 KB Output is correct
63 Correct 129 ms 7596 KB Output is correct
64 Correct 151 ms 7576 KB Output is correct
65 Correct 117 ms 4140 KB Output is correct
66 Correct 125 ms 4100 KB Output is correct
67 Correct 1 ms 384 KB Output is correct
68 Correct 1 ms 384 KB Output is correct
69 Correct 167 ms 8288 KB Output is correct
70 Correct 134 ms 6268 KB Output is correct
71 Correct 128 ms 6268 KB Output is correct
72 Correct 147 ms 7492 KB Output is correct
73 Correct 142 ms 7544 KB Output is correct