QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#472480#6412. Classical Geometry ProblemUESTC_DECAYALI#WA 0ms3972kbC++172.5kb2024-07-11 16:42:492024-07-11 16:42:50

Judging History

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

  • [2024-07-11 16:42:50]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3972kb
  • [2024-07-11 16:42:49]
  • 提交

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;
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;

        C0.x = (T0.x <= 127 ? 0 : 255);
        C0.y = (T0.y <= 127 ? 0 : 255);
        C0.z = (T0.z <= 127 ? 255 : 0);
        tz1 = (T0.z <= 127 ? 0 : 255);
        if (255==tz1) ++m;
        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;

        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 ? 255 : 0);
        if (255==ty2) ++m;
        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;

        // 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);
        printf("%lld\n", m);
        if (tz1==255) printf("0 0 255 255\n");
        if (ty2==255) printf("0 255 %lld 255\n", tz1);
        printf("255 %lld %lld %.10Lf\n", ty2, tz1, abs(T2.x));
        // cout << 255 << ' ' << ty2 << ' ' << tz1 << ' ' << abs(T2.x) << '\n';
        printf("%lld %lld %lld %.10Lf\n", (int)C1.x, (int)C1.y, (int)C1.z, abs(tt2));
        // cout << C1.x << ' ' << C1.y << ' ' << C1.z << ' ' << abs(tt2) << '\n';
        printf("%lld %lld %lld %.10Lf\n", (int)C0.x, (int)C0.y, (int)C0.z, abs(tt1));
        // cout << C0.x << ' ' << C0.y << ' ' << C0.z << ' ' << abs(tt1) << '\n';
    }
    return 0;
}

詳細信息

Test #1:

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

input:

3
105 255 175
174 174 174
0 0 0

output:

5
0 0 255 255
0 255 255 255
255 255 255 153.0000000000
0 0 255 0.0000000000
0 255 0 93.2952303175
5
0 0 255 255
0 255 255 255
255 255 255 255.0000000000
0 0 255 167.8769030507
255 255 0 96.9774205427
4
0 255 0 255
255 255 0 0.0000000000
0 0 0 0.0000000000
0 0 255 0.0000000000

result:

wrong answer too far from the target: (0.000000, 255.000000, 0.000000) instead of (0, 0, 0) (test case 3)