답안 #255960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
255960 2020-08-02T07:04:17 Z 최은수(#5029) Mixture (BOI20_mixture) C++17
60 / 100
145 ms 14840 KB
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;
int zp,zm,zc;
inline bool cmpf(const pl&x,const pl&y)
{
    return x.se*y.fi<y.se*x.fi;
}
struct cmp
{
    inline bool operator()(const pl&x,const pl&y)const
    {
        return x.se*y.fi<y.se*x.fi;
    }
};
inline ll mygcd(ll x,ll y)
{
    while(y!=0)
        x%=y,swap(x,y);
    return x;
}
map<pl,int,cmp>pc,mc;
ll cmt;
pl bot[100010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll aa,bb,cc;
    cin>>aa>>bb>>cc;
    int flag=0;
    if(aa==0)
    {
        if(bb!=0)
            flag=1,swap(aa,bb);
        else
            flag=2,swap(aa,cc);
    }
    int tc;
    cin>>tc;
    int bct=0;
    for(int ti=0;ti<tc;ti++)
    {
        char tp;
        cin>>tp;
        if(tp=='A')
        {
            int id=++bct;
            ll a,b,c;
            cin>>a>>b>>c;
            if(flag==1)
                swap(a,b);
            else if(flag==2)
                swap(a,c);
            ll x=b*aa-bb*a;
            ll y=c*aa-cc*a;
            if(x!=0||y!=0)
            {
                ll g=abs(mygcd(x,y));
                x/=g;
                y/=g;
            }
            bot[id]=pl(x,y);
            if(x==0)
            {
                if(y==0)
                    zc++;
                else
                    (y==1?zp:zm)++;
            }
            else if(x>0)
            {
                cmt+=mc[pl(x,y)];
                pc[pl(x,y)]++;
            }
            else
            {
                cmt+=pc[pl(-x,-y)];
                mc[pl(-x,-y)]++;
            }
        }
        else
        {
            int id;
            cin>>id;
            ll x=bot[id].fi;
            ll y=bot[id].se;
            if(x==0)
            {
                if(y==0)
                    zc--;
                else
                    (y==1?zp:zm)--;
            }
            else if(x>0)
            {
                pc[pl(x,y)]--;
                cmt-=mc[pl(x,y)];
            }
            else
            {
                mc[pl(-x,-y)]--;
                cmt-=pc[pl(-x,-y)];
            }
        }
        while(!pc.empty()&&pc.begin()->se==0)
            pc.erase(pc.begin());
        while(!pc.empty()&&pc.rbegin()->se==0)
            pc.erase(--pc.end());
        while(!mc.empty()&&mc.begin()->se==0)
            mc.erase(mc.begin());
        while(!mc.empty()&&mc.rbegin()->se==0)
            mc.erase(--mc.end());
        if(zc>0)
            cout<<"1\n";
        else if((zp>0&&zm>0)||cmt>0)
            cout<<"2\n";
        else if(pc.empty()||mc.empty())
            cout<<"0\n";
        else
        {
            bool f1=cmpf(pc.begin()->fi,mc.rbegin()->fi)||zm>0;
            bool f2=cmpf(mc.begin()->fi,pc.rbegin()->fi)||zp>0;
            if(f1&&f2)
                cout<<"3\n";
            else
                cout<<"0\n";
        }
    }
    cout.flush();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 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 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 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 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 0 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 0 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 0 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 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 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 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 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 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 0 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 0 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 0 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 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 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 488 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 512 KB Output is correct
44 Correct 2 ms 512 KB Output is correct
45 Correct 1 ms 512 KB Output is correct
46 Correct 3 ms 640 KB Output is correct
47 Correct 4 ms 640 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 2 ms 384 KB Output is correct
51 Correct 4 ms 640 KB Output is correct
52 Correct 3 ms 512 KB Output is correct
53 Correct 4 ms 640 KB Output is correct
54 Correct 4 ms 640 KB Output is correct
55 Correct 2 ms 512 KB Output is correct
56 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 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 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 0 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 0 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 0 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 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 1 ms 384 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 488 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 512 KB Output is correct
44 Correct 2 ms 512 KB Output is correct
45 Correct 1 ms 512 KB Output is correct
46 Correct 3 ms 640 KB Output is correct
47 Correct 4 ms 640 KB Output is correct
48 Correct 2 ms 384 KB Output is correct
49 Correct 2 ms 384 KB Output is correct
50 Correct 2 ms 384 KB Output is correct
51 Correct 4 ms 640 KB Output is correct
52 Correct 3 ms 512 KB Output is correct
53 Correct 4 ms 640 KB Output is correct
54 Correct 4 ms 640 KB Output is correct
55 Correct 2 ms 512 KB Output is correct
56 Correct 2 ms 512 KB Output is correct
57 Correct 0 ms 512 KB Output is correct
58 Correct 6 ms 928 KB Output is correct
59 Correct 8 ms 768 KB Output is correct
60 Correct 5 ms 768 KB Output is correct
61 Correct 10 ms 1152 KB Output is correct
62 Correct 12 ms 1152 KB Output is correct
63 Correct 82 ms 7160 KB Output is correct
64 Correct 95 ms 7288 KB Output is correct
65 Correct 109 ms 9592 KB Output is correct
66 Correct 113 ms 9592 KB Output is correct
67 Correct 0 ms 384 KB Output is correct
68 Correct 0 ms 384 KB Output is correct
69 Correct 145 ms 14840 KB Output is correct
70 Incorrect 136 ms 12536 KB Output isn't correct
71 Halted 0 ms 0 KB -