Submission #586954

# Submission time Handle Problem Language Result Execution time Memory
586954 2022-07-01T06:24:08 Z 박상훈(#8395) Mixture (BOI20_mixture) C++17
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
ll myabs(ll x){
    if (x<0) return -x;
    return x;
}
struct Vec3{
    ll x, y, z;
    Vec3(){}
    Vec3(ll _x, ll _y, ll _z): x(_x), y(_y), z(_z) {}

    Vec3 c(){
        if (x<0) x = -x, y = -y, z = -z;
        ll g = __gcd(myabs(x), __gcd(myabs(y), myabs(z)));
        x /= g, y /= g, z /= g;
        return *this;
    }

    Vec3 operator * (const Vec3 &V) const{
        return Vec3(y*V.z - z*V.y, z*V.x - x*V.z, x*V.y - y*V.x);
    }

    bool operator < (const Vec3 &V) const{
        return tie(x, y, z) < tie(V.x, V.y, V.z);
    }

    bool operator == (const Vec3 &V) const{
        return x==V.x && y==V.y && z==V.z;
    }
}a[100100];

multiset<Vec3> s1, s2;
bool on[100100];

int main(){
    Vec3 v0;
    scanf("%lld %lld %lld", &v0.x, &v0.y, &v0.z);
    v0.c();

    int q, j = 1, ans2 = 0;
    scanf("%d", &q);

    for (int i=1;i<=q;i++){
        char op;
        scanf(" %c", &op);

        if (op=='A'){
            scanf("%lld %lld %lld", &a[j].x, &a[j].y, &a[j].z);
            a[j].c();
            on[j] = 1;
            s1.insert(a[j]);

            if (!(a[j]==v0)){
                auto iter = s2.insert((a[j]*v0).c());
                if (iter!=s2.begin() && *prev(iter)==*iter) ans2++;
                else if (next(iter)!=s2.end() && *next(iter)==*iter) ans2++;
            }

            j++;
        }
        else{
            int k;
            scanf("%d", &k);
            on[k] = 0;

            s1.erase(s1.find(a[k]));

            if (!(a[k]==v0)){
                auto iter = s2.find((a[k]*v0).c());
                if (iter!=s2.begin() && *prev(iter)==*iter) ans2--;
                else if (next(iter)!=s2.end() && *next(iter)==*iter) ans2--;
                s2.erase(iter);
            }

        }

        if (s1.find(v0)!=s1.end()) {printf("1\n"); continue;}
        if (ans2) {printf("2\n"); continue;}

        bool flag3 = 0;
        Vec3 V1(0, 0, 0), V2(0, 0, 0);
        for (int z=1;z<j;z++) if (on[z]){
            if (V1==Vec3(0, 0, 0)){
                V1 = a[z]; continue;
            }

            if (V1==a[z]) continue;
            if (V2==Vec3(0, 0, 0)){
                V2 = (V1 * a[z]).c(); continue;
            }
            else{
                if(V2==(V1 * a[z]).c()) continue;
                else {flag3 = 1; break;}
            }
        }
        if (flag3) printf("3\n");
        else printf("0\n");
    }
    return 0;
}

Compilation message

Mixture.cpp: In function 'int main()':
Mixture.cpp:39:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     scanf("%lld %lld %lld", &v0.x, &v0.y, &v0.z);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mixture.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
Mixture.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         scanf(" %c", &op);
      |         ~~~~~^~~~~~~~~~~~
Mixture.cpp:50:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |             scanf("%lld %lld %lld", &a[j].x, &a[j].y, &a[j].z);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mixture.cpp:65:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |             scanf("%d", &k);
      |             ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -