답안 #587034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587034 2022-07-01T08:40:04 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 inv(){
        return Vec3(-x, -y, -z);
    }

    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;}
        bool flag2 = 0;
        for (int z=1;z<j;z++) if (on[z]){
            if (s2.find((a[z]*v0).c().inv())!=s2.end()) {flag2 = 1; break;}
        }

        if (flag2) {printf("2\n"); continue;}


        printf("0\n");
    }
    return 0;
}

Compilation message

Mixture.cpp: In function 'int main()':
Mixture.cpp:60:22: warning: variable 'iter' set but not used [-Wunused-but-set-variable]
   60 |                 auto iter = s2.insert((a[j]*v0).c());
      |                      ^~~~
Mixture.cpp:46:19: warning: unused variable 'ans2' [-Wunused-variable]
   46 |     int q, j = 1, ans2 = 0;
      |                   ^~~~
Mixture.cpp:43:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |     scanf("%lld %lld %lld", &v0.x, &v0.y, &v0.z);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mixture.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
Mixture.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         scanf(" %c", &op);
      |         ~~~~~^~~~~~~~~~~~
Mixture.cpp:54:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |             scanf("%lld %lld %lld", &a[j].x, &a[j].y, &a[j].z);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Mixture.cpp:69:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |             scanf("%d", &k);
      |             ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 1 ms 212 KB Output isn't correct
4 Halted 0 ms 0 KB -