QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#472594#6412. Classical Geometry ProblemUESTC_DECAYALI#WA 0ms3980kbC++173.0kb2024-07-11 17:27:162024-07-11 17:27:17

Judging History

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

  • [2024-07-11 17:27:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3980kb
  • [2024-07-11 17:27:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long

using LD = long double;
LD eps = 1e-8;
LD sqr(LD x){return x*x;}
int sgn(LD x){return fabs(x)<=eps ? 0 : (x>eps ? 1 : -1);}

struct Pt{
    LD x, y, z;
    Pt operator*(const LD &b)const{return Pt{x*b, y*b, z*b};}
    Pt operator-(const Pt &b)const{return Pt{x-b.x, y-b.y, z-b.z};}
    Pt operator+(const Pt &b)const{return Pt{x+b.x, y+b.y, z+b.z};}
    LD len()const{return sqrt(x*x+y*y+z*z);}
    Pt unit()const{return (*this)*(1/len());}
};

int t;
struct Node{
    int x, y, z;
    LD tt;
    void ppp(){
        printf("%lld %lld %lld %.10Lf\n", x, y, z, abs(tt));
    }
};
vector<Node> ans;
signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(10);
    cin >> t;
    while (t--){
        Pt T0, C0, V0, T1, C1, V1, T2;
        int tz1, ty2;
        int m=3;
        cin >> T0.x >> T0.y >> T0.z;

        if (sgn(T0.x)==0 && sgn(T0.y)==0 && sgn(T0.z)==0){
            printf("0\n");
            continue;
        }

        if (0==sgn(T0.z) || 0==sgn(T0.z-255)){
            tz1 = (int)T0.z;
        }else{
            C0.x = (T0.x <= 127 ? 0 : 255);
            C0.y = (T0.y <= 127 ? 0 : 255);
            C0.z = (T0.z > 127 ? 0 : 255);
            tz1 = (T0.z <= 127 ? 0 : 255);
            LD tt1;
            if (sgn(T0.z-C0.z)==0) tt1=0;
            else{
                V0 = (T0-C0).unit();
                tt1 = (tz1-T0.z)/V0.z;
            }
            T1 = T0 + V0*tt1;
            ans.push_back(Node{C0.x, C0.y, C0.z, tt1});
        }

        if (0==sgn(T1.y) || 0==sgn(T1.y-255)){
            ty2 = (int)T1.y;
        }else{
            C1.z = tz1;
            C1.x = (sgn(T1.y-T1.x)>=0 ? 0 : 255);
            C1.y = (sgn(T1.y-T1.x)>=0 ? 0 : 255);
            ty2 = (sgn(T1.y-T1.x)<0 ? 0 : 255);
            LD tt2;
            if (sgn(T1.y-C1.y)==0) tt2=0;
            else{
                V1 = (T1-C1).unit();
                tt2 = (ty2-T1.y)/V1.y;
            }
            T2 = T1 + V1*tt2;
            ans.push_back(Node{C1.x, C1.y, C1.z, tt2});
        }
        // printf("tz1=%lld ty2=%lld\n", tz1, ty2);
        // printf("T2(%Lf %Lf %Lf)\n", T2.x, T2.y, T2.z);
        // printf("V1(%Lf %Lf %Lf)\n", V1.x, V1.y, V1.z);
        // printf("T1(%Lf %Lf %Lf)\n", T1.x, T1.y, T1.z);
        // printf("V0(%Lf %Lf %Lf)\n", V0.x, V0.y, V0.z);
        // printf("T0(%Lf %Lf %Lf)\n", T0.x, T0.y, T0.z);
        if (sgn(T2.x)>0) ans.push_back(Node{255, T2.y, T2.z, T2.x});
        if (sgn(T2.y)>0) ans.push_back(Node{0, 255, T2.z, T2.y});
        if (sgn(T2.z)>0) ans.push_back(Node{0, 0, 255, T2.z});
        m = ans.size();
        printf("%lld\n", m); 
        for (int i=m-1; i>=0; --i){
            auto [x0, y0, z0, tt0] = ans[i];
            printf("%lld %lld %lld %.10Lf\n", x0, y0, z0, tt0);
        }
        // cout << C0.x << ' ' << C0.y << ' ' << C0.z << ' ' << abs(tt1) << '\n';
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3980kb

input:

3
105 255 175
174 174 174
0 0 0

output:

1
0 255 0 93.2952303175
6
0 0 255 255.0000000000
0 255 255 255.0000000000
255 255 255 255.0000000000
0 0 255 167.8769030507
255 255 0 96.9774205427
0 255 0 93.2952303175
0

result:

wrong answer too far from the target: (0.000000, 93.295230, 0.000000) instead of (105, 255, 175) (test case 1)