QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#154246 | #6412. Classical Geometry Problem | PhantomThreshold# | WA | 87ms | 3908kb | C++20 | 2.1kb | 2023-08-31 15:40:51 | 2023-08-31 15:40:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long double db;
const db eps=0;
int sign(db k){
if (k<-eps) return -1;
else if (k>eps) return 1;
return 0;
}
int cmp(db k1,db k2){return sign(k1-k2);}
struct point{
db x,y,z;
point operator + (const point &k){return (point){x+k.x,y+k.y,z+k.z};}
point operator - (const point &k){return (point){x-k.x,y-k.y,z-k.z};}
point operator * (db k){return (point){x*k,y*k,z*k};}
point operator / (db k){return (point){x/k,y/k,z/k};}
db abs2(){return x*x+y*y+z*z;}
db abs(){return hypot(hypot(x,y),z);}
db dis(point k){return ((*this)-k).abs();}
point unit(){
db d=abs();
return (point){x/d,y/d,z/d};
}
void print(){
cerr << "(" << x << "," << y << "," << z << ") ";
}
};
int main(){
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(12);
int T;
cin >> T;
for (;T--;){
int x,y,z;
cin >> x >> y >> z;
if (x==0 && y==0 && z==0){
cout << 0 << "\n";
continue;
}
if ((x==0 || x==255) && (y==0 || y==255) && (z==0 || z==255)){
cout << 1 << "\n";
cout << x << " " << y << " " << z << " " << 1000.0 << "\n";
}
point ed=(point){(db)x,(db)y,(db)z};
point P=(point){sign(ed.x)==0?0.0:255.0,sign(ed.y)==0?0.0:255.0,sign(ed.z)==0?0.0:255.0};
vector<pair<point,db>> ans;
for (int cc=1;cc<=3;cc++){
// ed.print();P.print();
// cerr << endl;
point dir=(ed-P).unit();
db l=0,r=1000;
for (int tt=1;tt<=100;tt++){
db mid=(l+r)/2;
point tmp=ed+dir*mid;
if (sign(tmp.x)<0 || sign(tmp.y)<0 || sign(tmp.z)<0) r=mid;
else l=mid;
}
point nxt=ed+dir*l;
ans.emplace_back(P,l);
ed=nxt;
if (sign(ed.x)==0) ed.x=0;
if (sign(ed.y)==0) ed.y=0;
if (sign(ed.z)==0) ed.z=0;
P=(point){sign(ed.x)==0?0.0:255.0,sign(ed.y)==0?0.0:255.0,sign(ed.z)==0?0.0:255.0};
if (sign(P.x)==0 && sign(P.y)==0 && sign(P.z)==0) break;
}
reverse(ans.begin(),ans.end());
cout << (int)ans.size() << "\n";
for (auto [P,t]:ans){
int x=P.x+0.5;
int y=P.y+0.5;
int z=P.z+0.5;
cout << x << " " << y << " " << z << " " << t << "\n";
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3908kb
input:
3 105 255 175 174 174 174 0 0 0
output:
3 0 255 0 1000.000000000000 0 255 255 119.000000000000 255 255 255 119.000000000000 1 255 255 255 301.376840516985 0
result:
ok ok (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 87ms
memory: 3824kb
input:
10000 250 128 13 1 245 2 88 183 138 179 69 194 153 246 33 255 119 192 233 30 108 26 208 33 53 162 189 225 130 10 202 137 121 152 198 25 49 165 180 228 56 30 74 18 14 6 115 31 168 242 206 90 238 139 44 103 60 16 21 190 229 209 68 41 171 181 39 74 73 181 96 18 234 95 70 75 174 84 101 16 44 202 249 80 ...
output:
3 255 0 0 244.960629921260 255 255 0 121.271562481707 255 255 255 14.683872523535 3 0 255 0 244.920948616601 0 255 255 1.004720917329 255 255 255 1.411981404758 3 0 255 0 98.076923076923 0 255 255 89.645464491727 255 255 255 113.949582887387 3 0 0 255 50.328947368421 255 0 255 193.374653313657 255 2...
result:
wrong answer too far from the target: (75.718262, 75.718262, 75.718262) instead of (255, 119, 192) (test case 6)