# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
255950 |
2020-08-02T06:52:44 Z |
최은수(#5029) |
Mixture (BOI20_mixture) |
C++17 |
|
1 ms |
384 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 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;
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 |
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 |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Incorrect |
0 ms |
384 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |