Submission #258141

#TimeUsernameProblemLanguageResultExecution timeMemory
258141mieszko11bMixture (BOI20_mixture)C++14
0 / 100
2 ms416 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; using ll = long long; using ld = long double; using ii = pair<int, int>; using pll = pair<ll, ll>; using uid = uniform_int_distribution<int>; using point = pair<ld, ld>; using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; using ordered_multiset = tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>; const int inf = int(1e9) + 7; const ll INF = ll(1e18) + 7; const ld EPS = 1e-8; #define X first #define Y second //~ mt19937 rng(chrono::steady_clock().now().time_since_epoch().count()); //~ int rand(int a, int b) { //~ return uid(a, b)(rng); //~ } void boost() { ios_base::sync_with_stdio(0); cin.tie(0); } int s, p, g; vector<pair<point, int> > P; point M; point norm(int s, int p, int g) { ld sum = s + p + g; return {ld(s) / sum, ld(p) / sum}; } bool equ(ld a, ld b) { return abs(a - b) < EPS; } ld cross(point o, point a, point b) { ld x1 = a.X - o.X; ld y1 = a.Y - o.Y; ld x2 = b.X - o.X; ld y2 = b.Y - o.Y; return x1 * y2 - x2 * y1; } int sign(ld x) { if(x < 0) return -1; if(x > 0) return 1; return 0; } void solve() { scanf("%d%d%d", &s, &p, &g); M = norm(s, p, g); int n; scanf("%d", &n); int cnt = 0; while(n--) { char c; scanf(" %c", &c); if(c == 'A') { int a, b, c; scanf("%d%d%d", &a, &b, &c); cnt++; P.emplace_back(norm(a, b, c), cnt); } else { int r; scanf("%d", &r); for(int i = 0 ; i < P.size() ; i++) { if(P[i].Y == r) { P.erase(P.begin() + i); break; } } } int res = 0; for(int i = 0 ; i < P.size() ; i++) { for(int j = i + 1 ; j < P.size() ; j++) { for(int k = j + 1 ; k < P.size() ; k++) { point a = P[i].X; point b = P[j].X; point c = P[k].X; if(sign(cross(a, b, M)) == sign(cross(b, c, M)) && sign(cross(b, c, M)) == sign(cross(c, a, M))) res = 3; } } } for(int i = 0 ; i < P.size() ; i++) { for(int j = i + 1 ; j < P.size() ; j++) { point a = P[i].X; point b = P[j].X; if(!equ(cross(a, b, M), 0)) continue; if(a.X < b.X && (M.X < a.X || M.X > b.X)) continue; if(a.Y < b.Y && (M.Y < a.Y || M.Y > b.Y)) continue; res = 2; } } for(auto p : P) if(equ(p.X.X, M.X) && equ(p.X.Y, M.Y)) res = 1; printf("%d\n", res); } } int main() { //~ boost(); int t = 1; //~ scanf("%d", &t); while(t--) { solve(); } return 0; }

Compilation message (stderr)

Mixture.cpp: In function 'void solve()':
Mixture.cpp:80:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i = 0 ; i < P.size() ; i++) {
                    ~~^~~~~~~~~~
Mixture.cpp:90:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0 ; i < P.size() ; i++) {
                   ~~^~~~~~~~~~
Mixture.cpp:91:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = i + 1 ; j < P.size() ; j++) {
                        ~~^~~~~~~~~~
Mixture.cpp:92:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int k = j + 1 ; k < P.size() ; k++) {
                         ~~^~~~~~~~~~
Mixture.cpp:103:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0 ; i < P.size() ; i++) {
                   ~~^~~~~~~~~~
Mixture.cpp:104:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = i + 1 ; j < P.size() ; j++) {
                        ~~^~~~~~~~~~
Mixture.cpp:64:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &s, &p, &g);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Mixture.cpp:67:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
Mixture.cpp:71:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c", &c);
   ~~~~~^~~~~~~~~~~
Mixture.cpp:74:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d%d%d", &a, &b, &c);
    ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Mixture.cpp:79:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &r);
    ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...