QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#108053 | #6412. Classical Geometry Problem | whatever# | AC ✓ | 35ms | 3708kb | C++17 | 2.0kb | 2023-05-23 15:12:20 | 2023-05-23 15:12:23 |
Judging History
answer
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#define x first
#define y second
#define point vec
#define eps (1e-4)
#define mp std::make_pair
#define pb push_back
#define db double
#define ld long double
using std::string;
using std::pair;
using std::abs;
using std::sqrt;
using std::max;
using std::vector;
const int L=255;
int T, stk[100], top;
ld x, y, z, nx, ny, nz, d[100];
inline ld sq(ld x) { return (ld)x*x; }
inline ld dis(ld a, ld b, ld c)
{
return sqrt(sq(a-x)+sq(b-y)+sq(c-z));
}
int main()
{
scanf("%d", &T);
while(T--)
{
scanf("%Lf%Lf%Lf", &x, &y, &z);
top=0;
int a=(x*2>L), b=(y*2>L), c=(z*2<L);
stk[++top]=a|(b<<1)|(c<<2);
ld k=(c?z/(L-z):(L-z)/z);
// printf("k %Lf %d\n", k, c);
nx=k*(x-a*L)+x, ny=k*(y-b*L)+y, nz=(c?0:L);
d[top]=dis(nx, ny, nz);
x=nx, y=ny, z=nz;
c^=1;
// printf("now %Lf %Lf %Lf %d\n", x, y, z, c);
stk[++top]=3|(c<<2);
if(abs(nx-L)>eps||abs(ny-L)>eps)
{
if(x<y)
{
nx=0, ny=L-(L-y)*(L/(L-x));
}
else
{
ny=0, nx=L-(L-x)*(L/(L-y));
}
d[top]=dis(nx, ny, nz);
x=nx, y=ny;
}
else
{
d[top]=L;
x=0, y=L;
}
// printf("now %Lf %Lf %Lf\n", x, y, z);
if(abs(x)<eps)
{
stk[++top]=2|(c<<2);
d[top]=y;
y=0;
}
else
{
stk[++top]=1|(c<<2);
d[top]=x;
x=0;
}
if(z>1) stk[++top]=4, d[top]=z, z=0;
printf("%d\n", top);
for(int i=top; i; --i) printf("%d %d %d %.6Lf\n", L*(stk[i]&1), L*((stk[i]>>1)&1), L*((stk[i]>>2)&1), d[i]);
// x=0, y=0, z=0;
// for(int i=top; i; --i)
// {
// int a=L*(stk[i]&1), b=L*((stk[i]>>1)&1), c=L*((stk[i]>>2)&1);
// ld cd=dis(a, b, c);
// ld rd=std::min(d[i], cd);
// if(cd<eps) continue;
// x+=(a-x)*rd/cd, y+=(b-y)*rd/cd, z+=(c-z)*rd/cd;
// printf("ok %Lf %Lf %Lf\n", x, y, z);
// }
// printf("final %.6Lf %.6Lf %.6Lf\n", x, y, z);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3704kb
input:
3 105 255 175 174 174 174 0 0 0
output:
4 0 0 255 255.000000 0 255 255 255.000000 255 255 255 153.000000 0 255 0 93.295230 4 0 0 255 255.000000 0 255 255 0.000000 255 255 255 192.747555 255 255 0 96.977421 3 0 255 0 0.000000 255 255 0 0.000000 0 0 255 0.000000
result:
ok ok (3 test cases)
Test #2:
score: 0
Accepted
time: 33ms
memory: 3660kb
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.960630 255 255 0 121.271562 255 255 255 14.683873 3 0 255 0 244.880952 255 255 0 1.008698 0 255 255 2.001577 4 0 0 255 255.000000 255 0 255 77.916667 255 255 255 148.479403 0 255 0 151.597374 4 0 0 255 255.000000 255 0 255 99.960000 255 255 255 106.143783 255 0 0 69.012848 3 0 255 0 23...
result:
ok ok (10000 test cases)
Test #3:
score: 0
Accepted
time: 18ms
memory: 3448kb
input:
10000 90 173 87 39 251 59 39 43 150 106 29 130 52 55 180 236 225 70 171 15 48 92 133 240 182 226 10 126 139 105 196 7 204 32 131 193 27 96 218 67 29 33 159 9 251 130 111 243 226 69 39 198 131 80 108 169 147 45 36 170 76 138 251 55 235 186 224 165 48 51 133 173 225 14 226 234 70 139 178 92 174 138 24...
output:
3 255 0 0 12.439024 255 255 0 180.159081 0 255 255 107.445062 3 0 255 0 248.503185 255 255 0 50.756261 0 255 255 60.168701 4 0 0 255 255.000000 0 255 255 9.189189 255 255 255 92.088445 0 0 0 112.589076 4 0 0 255 255.000000 255 0 255 194.405941 255 255 255 58.468559 0 0 0 163.679154 4 0 0 255 255.000...
result:
ok ok (10000 test cases)
Test #4:
score: 0
Accepted
time: 32ms
memory: 3536kb
input:
10000 186 217 161 76 0 116 246 159 161 32 245 65 206 120 71 217 76 204 109 255 245 157 59 192 55 35 87 27 147 199 190 134 31 169 64 105 5 27 255 161 2 35 244 255 232 253 106 199 28 151 129 50 24 20 172 236 234 74 51 150 179 68 178 69 42 192 152 1 23 177 169 71 216 190 125 136 223 193 255 168 49 74 2...
output:
4 0 0 255 255.000000 0 255 255 114.565217 255 255 255 166.350432 255 255 0 104.647849 3 255 0 0 139.424460 255 255 0 0.000000 0 0 255 132.206892 4 0 0 255 255.000000 255 0 255 231.093750 255 255 255 103.401739 255 255 0 109.568148 3 0 255 0 238.860759 255 255 0 43.033301 0 255 255 66.004155 3 255 0 ...
result:
ok ok (10000 test cases)
Test #5:
score: 0
Accepted
time: 23ms
memory: 3504kb
input:
10000 26 6 234 114 6 172 198 19 173 214 204 1 104 186 218 199 182 82 47 240 186 223 240 143 184 99 164 184 155 37 185 4 114 49 253 17 239 214 37 0 231 38 73 245 212 121 102 155 86 234 219 157 173 216 236 46 65 103 67 130 27 253 105 83 105 197 81 93 254 47 206 225 207 110 24 38 119 248 76 243 180 10 ...
output:
4 0 0 255 255.000000 255 0 255 22.368421 255 255 255 8.850517 0 0 0 21.136092 4 0 0 255 255.000000 255 0 255 165.903614 255 255 255 9.422684 0 0 0 99.617580 4 0 0 255 255.000000 255 0 255 160.616883 255 255 255 29.862569 255 0 0 86.804613 3 255 0 0 50.000000 255 255 0 261.490344 255 255 255 1.032652...
result:
ok ok (10000 test cases)
Test #6:
score: 0
Accepted
time: 22ms
memory: 3548kb
input:
10000 122 50 52 152 12 229 149 135 184 140 164 193 2 251 109 180 33 217 241 225 126 33 165 94 57 163 242 85 164 132 179 131 197 185 186 185 216 145 74 95 203 40 158 236 193 245 97 111 144 61 52 9 67 157 44 113 152 132 82 110 130 182 33 96 168 202 10 184 228 173 243 124 198 29 180 196 15 47 153 63 54...
output:
3 255 0 0 120.000000 255 255 0 71.066690 0 0 255 62.005494 4 0 0 255 255.000000 255 0 255 133.963134 255 255 255 14.791308 255 0 0 28.541434 4 0 0 255 255.000000 255 0 255 29.750000 255 255 255 118.343993 255 255 0 94.117376 4 0 0 255 255.000000 0 255 255 53.217391 255 255 255 131.419392 255 255 0 7...
result:
ok ok (10000 test cases)
Test #7:
score: 0
Accepted
time: 17ms
memory: 3612kb
input:
10000 218 94 126 189 17 30 100 251 196 67 123 128 157 60 0 161 139 95 179 210 67 98 91 45 186 227 63 242 172 226 173 1 24 66 118 98 194 75 112 189 176 43 243 226 174 112 93 67 202 143 142 117 216 97 108 179 239 161 97 91 233 111 216 110 231 208 195 20 203 43 24 22 189 205 79 98 167 102 230 139 185 1...
output:
3 0 255 0 13.783784 255 255 0 250.334992 255 0 255 160.037083 3 255 0 0 174.086538 255 255 0 20.213334 255 0 255 31.346097 4 0 0 255 255.000000 0 255 255 244.375000 255 255 255 130.214928 0 255 0 66.246379 4 0 0 255 255.000000 0 255 255 234.098361 255 255 255 133.924201 0 0 0 188.259571 3 255 0 0 12...
result:
ok ok (10000 test cases)
Test #8:
score: 0
Accepted
time: 26ms
memory: 3688kb
input:
10000 58 139 199 227 23 87 52 111 207 249 83 64 55 125 147 142 246 229 118 194 7 164 16 252 59 36 140 143 180 64 167 127 108 202 51 10 172 6 150 28 149 45 72 217 154 236 88 23 4 226 232 225 109 37 172 245 69 190 112 71 81 40 143 124 38 213 124 112 178 169 61 176 180 125 234 1 63 157 51 215 59 75 216...
output:
4 0 0 255 255.000000 0 255 255 45.212766 255 255 255 96.240804 0 255 0 66.842909 3 255 0 0 205.758621 255 255 0 35.555649 255 0 255 89.000647 4 0 0 255 255.000000 0 255 255 97.064516 255 255 255 75.349178 0 0 0 55.784384 3 255 0 0 240.833333 255 255 0 110.982392 255 0 255 69.810619 4 0 0 255 255.000...
result:
ok ok (10000 test cases)
Test #9:
score: 0
Accepted
time: 35ms
memory: 3668kb
input:
10000 154 183 17 8 28 144 3 227 218 175 43 0 209 191 38 123 96 107 56 179 204 230 197 204 188 100 217 43 189 158 161 254 191 83 240 178 150 193 187 123 122 48 157 207 135 103 84 235 62 53 66 77 2 234 237 56 156 219 127 51 184 225 70 138 102 218 53 203 153 39 98 75 171 45 134 159 215 212 128 35 190 1...
output:
3 0 255 0 73.217822 255 255 0 180.264898 255 255 255 19.170156 4 0 0 255 255.000000 0 255 255 37.500000 255 255 255 18.619919 0 0 0 113.246934 4 0 0 255 255.000000 0 255 255 221.790698 255 255 255 3.538808 0 255 0 37.307420 3 255 0 0 158.773585 255 255 0 45.959727 255 0 255 0.000000 3 255 0 0 71.718...
result:
ok ok (10000 test cases)
Test #10:
score: 0
Accepted
time: 31ms
memory: 3660kb
input:
10000 250 227 91 46 34 201 210 87 230 102 2 191 107 0 185 104 203 241 250 164 144 40 123 155 61 164 38 200 197 253 155 124 18 219 173 90 127 124 225 217 94 50 242 198 116 227 79 191 120 136 155 184 151 174 45 122 243 248 142 31 31 154 253 152 165 224 238 39 128 165 134 229 162 220 33 61 111 11 205 1...
output:
3 255 0 0 209.464286 255 255 0 214.808504 255 255 255 92.358447 4 0 0 255 255.000000 255 0 255 18.323353 255 255 255 58.850318 0 0 0 56.144112 4 0 0 255 255.000000 255 0 255 174.755245 255 255 255 101.119694 255 0 0 27.172609 4 0 0 255 255.000000 255 0 255 134.920635 255 255 255 2.951395 0 0 0 72.55...
result:
ok ok (10000 test cases)
Test #11:
score: 0
Accepted
time: 23ms
memory: 3708kb
input:
10000 208 135 142 248 171 248 162 65 32 9 162 63 91 20 90 188 236 117 62 200 71 14 228 53 68 196 133 27 159 255 129 86 121 46 216 3 213 65 177 7 28 45 215 136 153 108 54 113 254 122 99 243 222 89 18 255 48 14 157 204 210 33 132 87 4 33 231 222 233 30 14 100 10 45 226 49 210 232 113 79 18 235 109 14 ...
output:
4 0 0 255 255.000000 255 0 255 155.125000 255 255 255 42.429217 255 255 0 152.600034 4 0 0 255 255.000000 255 0 255 233.750000 255 255 255 169.213537 255 255 0 7.393276 3 255 0 0 104.905063 255 255 0 86.247244 255 0 255 35.903988 3 0 255 0 125.409836 255 255 0 13.408103 0 255 255 70.063716 3 255 0 0...
result:
ok ok (10000 test cases)
Test #12:
score: 0
Accepted
time: 32ms
memory: 3688kb
input:
10000 119 133 74 50 106 117 59 203 94 72 223 194 202 156 197 61 81 108 77 80 107 240 230 250 53 54 66 133 197 44 33 113 2 83 54 163 206 241 33 41 83 202 182 57 124 37 155 241 186 245 218 153 80 29 47 83 212 41 32 94 107 89 186 58 161 214 114 106 34 17 89 16 19 117 170 169 115 74 55 143 33 6 182 196 ...
output:
3 255 0 0 125.409836 255 255 0 93.239404 0 255 255 101.640891 3 0 255 0 162.272727 255 255 0 98.310227 0 0 255 153.501014 3 0 255 0 125.000000 255 255 0 104.890066 0 255 255 104.615270 4 0 0 255 255.000000 0 255 255 188.114754 255 255 255 97.840555 0 255 0 65.838994 4 0 0 255 255.000000 255 0 255 11...
result:
ok ok (10000 test cases)
Test #13:
score: 0
Accepted
time: 33ms
memory: 3692kb
input:
10000 170 100 234 20 253 12 243 196 46 206 129 235 149 5 166 232 179 7 149 75 45 98 197 156 206 22 133 230 176 54 159 228 135 170 92 118 90 61 180 9 26 18 21 65 122 40 143 87 125 192 199 176 35 144 44 85 243 153 238 203 227 9 212 200 74 226 253 135 20 139 117 222 230 43 212 42 201 224 22 222 152 191...
output:
4 0 0 255 255.000000 255 0 255 93.246269 255 255 255 129.049406 255 0 0 24.077555 3 0 255 0 252.713004 255 255 0 20.988498 0 255 255 12.040981 3 255 0 0 203.135593 255 255 0 186.761411 255 255 255 47.870687 4 0 0 255 255.000000 255 0 255 155.833333 255 255 255 126.905583 255 255 0 23.073406 4 0 0 25...
result:
ok ok (10000 test cases)
Test #14:
score: 0
Accepted
time: 21ms
memory: 3692kb
input:
10000 67 216 241 14 40 250 28 215 219 200 241 181 3 167 13 227 218 113 85 72 151 116 20 162 202 252 17 54 184 231 49 90 219 117 173 19 37 53 223 10 195 119 118 128 187 46 208 215 54 85 104 71 99 34 234 95 0 44 223 10 14 248 47 123 70 75 245 118 231 131 187 137 34 62 21 4 118 233 40 183 96 242 97 190...
output:
4 0 0 255 255.000000 0 255 255 197.844828 255 255 255 72.651028 0 255 0 14.706506 4 0 0 255 255.000000 0 255 255 28.093220 255 255 255 19.114933 0 0 0 5.071331 4 0 0 255 255.000000 0 255 255 201.596859 255 255 255 33.310021 0 255 0 36.883876 4 0 0 255 255.000000 0 255 255 190.090909 255 255 255 183....
result:
ok ok (10000 test cases)
Test #15:
score: 0
Accepted
time: 26ms
memory: 3552kb
input:
10000 252 245 224 4 171 9 240 190 208 69 15 254 4 230 90 0 255 17 6 26 58 150 187 237 239 242 146 255 227 231 232 117 26 44 255 111 183 1 9 121 85 207 15 245 120 247 181 40 1 255 164 244 139 255 131 248 27 161 24 241 63 44 16 207 36 251 15 227 163 49 7 180 27 7 23 61 254 235 14 8 11 200 7 3 26 254 3...
output:
4 0 0 255 255.000000 255 0 255 178.500000 255 255 255 254.342646 255 255 0 31.033653 3 0 255 0 166.487603 255 255 0 4.389023 0 255 255 9.511351 4 0 0 255 255.000000 255 0 255 196.153846 255 255 255 179.920037 255 255 0 49.357987 4 0 0 255 255.000000 255 0 255 57.615063 255 255 255 19.043404 0 0 0 1....
result:
ok ok (10000 test cases)
Test #16:
score: 0
Accepted
time: 20ms
memory: 3708kb
input:
10000 10 7 240 232 252 180 5 169 10 1 40 6 252 2 242 245 8 5 249 17 249 255 2 233 12 3 1 2 6 253 252 254 2 251 245 6 254 4 252 10 244 245 254 218 52 255 8 4 20 112 248 253 0 254 250 234 1 226 245 216 11 6 2 245 139 0 8 28 233 1 11 24 246 250 253 9 124 17 255 26 1 14 251 46 2 14 248 233 1 44 12 255 1...
output:
4 0 0 255 255.000000 255 0 255 3.283262 255 255 255 10.450719 0 0 0 15.019389 4 0 0 255 255.000000 0 255 255 221.739130 255 255 255 224.300700 255 255 0 75.620122 3 0 255 0 163.625000 255 255 0 5.528104 0 255 255 10.600150 3 0 255 0 40.100806 255 255 0 1.339264 0 0 255 6.076973 4 0 0 255 255.000000 ...
result:
ok ok (10000 test cases)
Test #17:
score: 0
Accepted
time: 21ms
memory: 3664kb
input:
10000 0 3 254 9 1 2 250 254 0 4 1 65 212 3 253 253 255 254 252 1 255 255 230 11 253 215 255 113 12 16 252 253 0 255 254 254 254 255 252 0 32 254 255 36 252 10 1 243 3 46 11 99 3 255 250 0 248 11 5 3 253 254 255 23 2 1 0 253 4 255 255 248 255 237 250 7 13 1 251 251 246 0 0 4 0 2 1 254 254 0 189 3 0 2...
output:
4 0 0 255 255.000000 0 255 255 3.011811 255 255 255 0.000000 0 0 0 1.000070 3 255 0 0 8.095238 255 255 0 1.402950 0 0 255 2.001281 3 0 255 0 204.000000 255 255 0 254.950976 255 255 255 0.000000 3 255 0 0 4.047619 255 255 0 1.883020 0 0 255 65.015303 4 0 0 255 255.000000 255 0 255 211.140000 255 255 ...
result:
ok ok (10000 test cases)
Test #18:
score: 0
Accepted
time: 20ms
memory: 3612kb
input:
10000 0 253 255 255 252 2 255 0 255 250 253 255 253 0 255 252 251 236 8 255 0 247 254 254 2 255 255 255 255 252 0 0 4 6 250 0 7 32 0 0 2 255 255 9 255 3 255 1 255 255 242 254 0 0 0 0 254 0 255 255 1 0 9 255 255 2 0 255 0 0 0 255 254 9 1 253 255 254 252 0 255 0 0 255 254 0 252 255 247 0 2 250 255 255...
output:
4 0 0 255 255.000000 0 255 255 253.000000 255 255 255 0.000000 0 255 0 0.000000 3 255 0 0 255.000000 255 255 0 251.976285 255 255 255 2.000141 4 0 0 255 255.000000 255 0 255 255.000000 255 255 255 0.000000 255 0 0 0.000000 4 0 0 255 255.000000 0 255 255 153.000000 255 255 255 269.258240 255 255 0 0....
result:
ok ok (10000 test cases)
Test #19:
score: 0
Accepted
time: 23ms
memory: 3652kb
input:
10000 0 0 0 255 0 255 0 255 255 255 255 1 0 0 0 0 255 1 255 0 254 0 255 0 0 203 255 0 2 0 255 0 255 255 254 0 255 0 255 255 255 228 0 255 255 0 255 255 0 254 0 253 0 0 242 0 0 255 0 0 255 252 0 0 0 0 0 0 0 255 255 255 0 0 255 255 255 0 4 255 0 0 1 0 0 0 255 0 253 253 0 255 255 0 0 255 255 0 0 1 255 ...
output:
3 0 255 0 0.000000 255 255 0 0.000000 0 0 255 0.000000 4 0 0 255 255.000000 255 0 255 255.000000 255 255 255 0.000000 255 0 0 0.000000 4 0 0 255 255.000000 0 255 255 255.000000 255 255 255 0.000000 0 255 0 0.000000 3 0 255 0 255.000000 255 255 0 255.000000 255 255 255 1.000000 3 0 255 0 0.000000 255...
result:
ok ok (10000 test cases)
Test #20:
score: 0
Accepted
time: 17ms
memory: 3472kb
input:
10000 0 0 0 0 255 255 255 0 255 255 255 0 255 255 255 255 0 0 255 255 255 0 0 255 0 0 0 0 0 255 255 255 0 0 0 255 255 0 0 0 0 0 255 255 0 0 0 255 0 0 0 255 255 0 0 0 255 0 255 0 255 0 255 0 255 255 0 255 0 0 255 0 1 0 255 255 0 254 255 0 255 255 255 255 0 255 255 255 0 255 255 0 255 0 255 255 255 25...
output:
3 0 255 0 0.000000 255 255 0 0.000000 0 0 255 0.000000 4 0 0 255 255.000000 0 255 255 255.000000 255 255 255 0.000000 0 255 0 0.000000 4 0 0 255 255.000000 255 0 255 255.000000 255 255 255 0.000000 255 0 0 0.000000 3 0 255 0 255.000000 255 255 0 255.000000 255 255 255 0.000000 4 0 0 255 255.000000 0...
result:
ok ok (10000 test cases)