QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#639813#9227. Henry the PlumberpropaneWA 0ms3636kbC++202.0kb2024-10-13 22:53:512024-10-13 22:53:52

Judging History

你现在查看的是最新测评结果

  • [2024-10-13 22:53:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-10-13 22:53:51]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<numeric>
using namespace std;
using LL = long long;

struct P3{
    int x, y, z;

    P3 operator+(const P3 &t) const {
        return {x + t.x, y + t.y, z + t.z};
    }

    P3 operator-(const P3 &t) const {
        return {x - t.x, y - t.y, z - t.z};
    }

    P3 operator*(int k) const {
        return {x * k, y * k, z * k};
    }

    P3 operator/(int k) const {
        return {x / k, y / k, z / k};
    }

    bool operator==(const P3 &t){
        return abs(x - t.x) < 0 && abs(y - t.y) < 0 && abs(z - t.z) < 0;
    }

    int operator*(const P3 &t) const {
        return x * t.x + y * t.y + z * t.z;
    }

    P3 operator^(const P3 &t) const {
        return {y * t.z - z * t.y, z * t.x - x * t.z, x * t.y - y * t.x};
    }

};

const P3 zero = {int(0), int(0), int(0)};

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int T;
    cin >> T;
    while(T--){
        P3 p1, p2;
        P3 d1, d2;
        cin >> p1.x >> p1.y >> p1.z;
        cin >> d1.x >> d1.y;
        d1.z = 0;
        cin >> p2.x >> p2.y >> p2.z;
        cin >> d2.x >> d2.y;
        d2.z = 0;
        if ((p2 - p1) * d1 == 0 and (p2 - p1) * d1 == 0){
            cout << 2 << '\n';
            continue;
        }
        // d1.x * (x - p1.x) + ...
        // ax + by + cz = v
        int a1 = d1.x, b1 = d1.y, c1 = d1.z, v1 = d1 * p1;
        int a2 = d2.x, b2 = d2.y, c2 = d2.z, v2 = d2 * p2;

        int l = lcm(a1, a2);

        auto f = [&](int &a, int &b, int &c, int &v){
            int t = l / a;
            a *= t; b *= t; c *= t; v *= t;
        };

        f(a1, b1, c1, v1);
        f(a2, b2, c2, v2);

        int k1 = b2 - b1, k2 = c2 - c1, k3 = v2 - v1;
        if (k1 == 0 and k2 == 0 and k3 != 0){
            cout << 4 << '\n';
        }
        else{
            cout << 3 << '\n';
        }
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3636kb

input:

2
-1 -1 3
1 1
2 2 3
2 2
5 5 1
3 0
7 6 -2
1 -2

output:

4
3

result:

ok 2 number(s): "4 3"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3580kb

input:

100
-13 -5 -7
-19 19
-19 -13 0
-7 15
-20 20 19
-17 18
20 -20 -1
18 -19
-18 15 -14
-19 18
19 -20 6
20 -19
-12 9 1
7 -16
-13 -14 -8
8 -13
-19 16 9
20 -19
19 -18 -11
19 -18
19 20 -8
12 20
-11 -9 18
-19 -18
8 11 -13
12 -18
18 13 8
4 -18
-16 20 17
-19 18
20 -18 -3
20 -19
-17 -20 -5
-18 -19
19 16 15
19 20...

output:

3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3

result:

wrong answer 1st numbers differ - expected: '4', found: '3'