Submission #255951

# Submission time Handle Problem Language Result Execution time Memory
255951 2020-08-02T06:54:56 Z 최은수(#5029) Mixture (BOI20_mixture) C++17
60 / 100
7 ms 1152 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;
}
multiset<pl,cmp>pls,mins;
map<pl,int>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)]++;
                pls.ep(x,y);
            }
            else
            {
                cmt+=pc[pl(-x,-y)];
                mc[pl(-x,-y)]++;
                mins.ep(-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)
            {
                pls.erase(pls.find(pl(x,y)));
                pc[pl(x,y)]--;
                cmt-=mc[pl(x,y)];
            }
            else
            {
                mins.erase(mins.find(pl(-x,-y)));
                mc[pl(-x,-y)]--;
                cmt-=pc[pl(-x,-y)];
            }
        }
        if(zc>0)
            cout<<"1\n";
        else if((zp>0&&zm>0)||cmt>0)
            cout<<"2\n";
        else if(pls.empty()||mins.empty())
            cout<<"0\n";
        else
        {
            bool f1=cmpf(*pls.begin(),*mins.rbegin())||zm>0;
            bool f2=cmpf(*mins.begin(),*pls.rbegin())||zp>0;
            if(f1&&f2)
                cout<<"3\n";
            else
                cout<<"0\n";
        }
    }
    cout.flush();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 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 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 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 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 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 1 ms 384 KB Output is correct
27 Correct 1 ms 328 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 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 0 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
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 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 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 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 1 ms 384 KB Output is correct
27 Correct 1 ms 328 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 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 0 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 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 1 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 768 KB Output is correct
47 Correct 4 ms 768 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 5 ms 896 KB Output is correct
52 Correct 4 ms 768 KB Output is correct
53 Correct 5 ms 1024 KB Output is correct
54 Correct 5 ms 1024 KB Output is correct
55 Correct 2 ms 512 KB Output is correct
56 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 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 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 1 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 1 ms 384 KB Output is correct
27 Correct 1 ms 328 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 384 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
33 Correct 0 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 512 KB Output is correct
40 Correct 1 ms 512 KB Output is correct
41 Correct 1 ms 512 KB Output is correct
42 Correct 1 ms 512 KB Output is correct
43 Correct 1 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 768 KB Output is correct
47 Correct 4 ms 768 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 5 ms 896 KB Output is correct
52 Correct 4 ms 768 KB Output is correct
53 Correct 5 ms 1024 KB Output is correct
54 Correct 5 ms 1024 KB Output is correct
55 Correct 2 ms 512 KB Output is correct
56 Correct 2 ms 512 KB Output is correct
57 Correct 3 ms 640 KB Output is correct
58 Correct 7 ms 1152 KB Output is correct
59 Runtime error 3 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
60 Halted 0 ms 0 KB -