#include <bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> ii;
typedef tuple<ll,ll,ll> iii;
ll gcd(ll a,ll b){
if(b==0)return a;
return gcd(b,a%b);
}
struct idk{
ll a,b,c;
inline idk mult(ll x){
return {a*x,b*x,c*x};
}
inline idk div(ll x){
return {a/x,b/x,c/x};
}
bool operator <(const idk &o) const{
return iii(a,b,c)<iii(o.a,o.b,o.c);
}
bool operator ==(const idk &o) const{
return iii(a,b,c)==iii(o.a,o.b,o.c);
}
};
int same=0,cnt2=0,cnt3=0;
idk t;
set<pair<int,idk>> s;
multiset<ii> d;
inline idk read(){
ll a,b,c;
sf("%lld%lld%lld",&a,&b,&c);
return {a,b,c};
}
inline ii lcmsub(idk &a, idk &b){
ll g=gcd(a.a,t.a);
idk x=a.mult(t.a/g),y=t.mult(a.a/g);
ii pr={x.b-y.b,x.c-y.c};
if(pr.fi==0&&pr.se==0)return {0,0};
g=gcd(abs(pr.fi),abs(pr.se));
pr={pr.fi/g,pr.se/g};
if(pr.fi==0)return {0,1};
else if(pr.se==0)return {1,0};
else return pr;
}
int main(){
t=read();
t=t.div(gcd(gcd(t.a,t.b),t.c));
int q;sf("%d",&q);
int cnt=0;
while(q--){
char c;sf(" %c",&c);
if(c=='A'){
++cnt;
idk a=read();
a=a.div(gcd(gcd(a.a,a.b),a.c));
s.insert({cnt,a});
if(a==t)++same;
ii pr=lcmsub(a,t);
if(d.count({-pr.fi,-pr.se})!=0&&d.count(pr)==0)++cnt2;
d.insert(pr);
if(d.count(pr)==2)++cnt3;
}
else{
int i;sf("%d",&i);
auto it=s.lower_bound({i,{0,0,0}});
auto a=(*it).se;
if(a==t)--same;
s.erase(it);
ii pr=lcmsub(a,t);
if(d.count({-pr.fi,-pr.se})!=0&&d.count(pr)==1)--cnt2;
d.erase(d.find(pr));
if(d.count(pr)==1)--cnt3;
}
if(same>0)pf("1\n");
else if(cnt2>0)pf("2\n");
else if(cnt3>0)pf("3\n");
else pf("0\n");
}
}
Compilation message
Mixture.cpp: In function 'int main()':
Mixture.cpp:59:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
59 | int q;sf("%d",&q);
| ^
Mixture.cpp:62:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
62 | char c;sf(" %c",&c);
| ^
Mixture.cpp:76:12: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
76 | int i;sf("%d",&i);
| ^
Mixture.cpp: In function 'idk read()':
Mixture.cpp:40:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | sf("%lld%lld%lld",&a,&b,&c);
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |