QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#472419 | #6412. Classical Geometry Problem | UESTC_DECAYALI# | WA | 0ms | 3868kb | C++17 | 2.2kb | 2024-07-11 16:18:22 | 2024-07-11 16:18:22 |
Judging History
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);
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);
cout << m << '\n';
if (tz1==255) cout << "0 0 255 255\n";
if (ty2==255) cout << "0 255 " << tz1 << " 255\n";
cout << 255 << ' ' << ty2 << ' ' << tz1 << ' ' << T2.x << '\n';
cout << C1.x << ' ' << C1.y << ' ' << C1.z << ' ' << tt2 << '\n';
cout << C0.x << ' ' << C0.y << ' ' << C0.z << ' ' << tt1 << '\n';
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3868kb
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 0 0 255 0 0 255 0 93.2952 5 0 0 255 255 0 255 255 255 255 255 255 255 0 0 255 167.877 255 255 0 96.9774 4 0 255 0 255 255 255 0 0 0 0 0 0 0 0 255 -0
result:
wrong answer too far from the target: (105.000016, 255.000000, 175.000026) instead of (105, 255, 175) (test case 1)