#include <iostream>
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
struct frac {
lli z;
lli d;
lli t;
bool operator < (const frac& other) const {
if (z * other.d == other.z * d) return t < other.t;
return z * other.d < other.z * d;
}
bool operator > (const frac& other) const {
if (z * other.d == other.z * d) return t > other.t;
return z * other.d > other.z * d;
}
bool operator <= (const frac& other) const {
return z * other.d <= other.z * d;
}
bool operator >= (const frac& other) const {
return z * other.d >= other.z * d;
}
frac operator - () const {
return frac({-z, d, t});
}
};
template <class T> struct les {
bool operator() (const T& x, const T& y) const {
return x < y;
}
typedef T first_argument_type;
typedef T second_argument_type;
typedef bool result_type;
};
std::ostream & operator<<(std::ostream & Str, frac const & v) {
Str << v.z << " " << v.d;
return Str;
}
int main() {
lli a, b, c;
cin >> a >> b >> c;
lli n;
cin >> n;
multiset<frac, les<frac>> pos, neg;
vector<frac> regal;
string op;
lli ta, tb, tc, r, z, posZ, negZ;
frac f;
z = 0;
posZ = 0;
negZ = 0;
for (int i = 0; i < n; ++i) {
//cout << i << "\n";
cin >> op;
if (op == "A") {
cin >> ta >> tb >> tc;
ta *= a;
tb *= a;
tc *= a;
tb -= ta / a * b;
tc -= ta / a * c;
f = frac({tb, tc, i});
regal.push_back(f);
if (f.z == 0 && f.d == 0) {
z++;
}
if (f.d == 0) {
if (f.z >= 0) posZ++; else negZ++;
}
if (f.d >= 0) {
pos.insert(f);
} else {
neg.insert(f);
}
} else {
cin >> r;
f = regal[r - 1];
if (f.z == 0 && f.d == 0) {
z--;
}
if (f.d == 0) {
if (f.z >= 0) posZ++; else negZ--;
}
if (f.d >= 0) {
pos.erase(f);
} else {
neg.erase(f);
}
}
/*
cout << "\npos\n";
for (auto a: pos) {
cout << a << "\n";
}
cout << "neg\n";
for (auto a: neg) {
cout << a << "\n";
}
cout << "\n";
*/
if (z > 0) {
cout << 1;
} else {
if (posZ > 0 && negZ > 0) cout << 2;
else if (pos.size() != 0 && neg.size() != 0) {
if (((*neg.begin()) <= (*--pos.end()) && (*neg.begin()) >= (*pos.begin())) || ((*--neg.end()) <= (*--pos.end()) && (*--neg.end()) >= (*pos.begin())) || ((*pos.begin()) <= (*--neg.end()) && (*pos.begin()) >= (*neg.begin())) || ((*--pos.end()) <= (*--neg.end()) && (*--pos.end()) >= (*neg.begin()))) {
cout << 2;
} else {
cout << 0;
}
} else {
cout << 0;
}
}
cout << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
292 KB |
Output is correct |
2 |
Correct |
1 ms |
284 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
292 KB |
Output is correct |
2 |
Correct |
1 ms |
284 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
292 KB |
Output is correct |
2 |
Correct |
1 ms |
284 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
292 KB |
Output is correct |
2 |
Correct |
1 ms |
284 KB |
Output is correct |
3 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |