QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#472634#6412. Classical Geometry ProblemUESTC_DECAYALIWA 20ms4008kbC++172.6kb2024-07-11 17:44:332024-07-11 17:44:34

Judging History

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

  • [2024-07-11 17:44:34]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:4008kb
  • [2024-07-11 17:44:33]
  • 提交

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;

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

        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);
        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 ? 0 : 255);
        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: 100
Accepted
time: 0ms
memory: 3808kb

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
1
0 0 0 0.0000000000

result:

ok ok (3 test cases)

Test #2:

score: 0
Accepted
time: 20ms
memory: 3932kb

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.9606299213
255 255 0 121.2715624817
255 255 255 14.6838725235
4
0 255 0 255
255 255 0 1.0493827160
0 0 0 10.0791367278
0 255 255 2.0015772812
4
0 0 255 255
255 0 255 77.9166666667
255 255 255 148.4794025055
0 255 0 151.5973736748
4
0 0 255 255
255 0 255 99.9600000000
255 255 255 106.14...

result:

ok ok (10000 test cases)

Test #3:

score: 0
Accepted
time: 20ms
memory: 3936kb

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.4390243902
255 255 0 180.1590806695
0 255 255 107.4450618992
4
0 255 0 255
255 255 0 51.7968750000
0 0 0 5.3103560920
0 255 255 60.1687013387
5
0 0 255 255
0 255 255 255
255 255 255 231.2790697674
0 0 255 245.5721960266
0 0 0 112.5890758466
4
0 0 255 255
255 0 255 194.4059405941
255 255...

result:

ok ok (10000 test cases)

Test #4:

score: 0
Accepted
time: 20ms
memory: 3780kb

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:

5
0 0 255 255
0 255 255 255
255 255 255 190.7317073171
0 0 255 75.1595849981
255 255 0 104.6478487794
3
255 0 0 139.4244604317
255 255 0 0.0000000000
0 0 255 132.2068915792
4
0 0 255 255
255 0 255 231.0937500000
255 255 255 103.4017391773
255 255 0 109.5681482967
4
0 255 0 255
255 255 0 45.333333333...

result:

ok ok (10000 test cases)

Test #5:

score: 0
Accepted
time: 20ms
memory: 3920kb

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
255 0 255 22.3684210526
255 255 255 8.8505173751
0 0 0 21.1360920057
4
0 0 255 255
255 0 255 165.9036144578
255 255 255 9.4226842532
0 0 0 99.6175800241
4
0 0 255 255
255 0 255 160.6168831169
255 255 255 29.8625692407
255 0 0 86.8046127608
3
255 0 0 50.0000000000
255 255 0 261.49034442...

result:

ok ok (10000 test cases)

Test #6:

score: 0
Accepted
time: 16ms
memory: 3872kb

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.0000000000
255 255 0 71.0666898830
0 0 255 62.0054941717
4
0 0 255 255
255 0 255 133.9631336406
255 255 255 14.7913083229
255 0 0 28.5414339392
4
0 0 255 255
255 0 255 29.7500000000
255 255 255 118.3439925265
255 255 0 94.1173759643
5
0 0 255 255
0 255 255 255
255 255 255 195.000000000...

result:

ok ok (10000 test cases)

Test #7:

score: 0
Accepted
time: 20ms
memory: 3944kb

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:

4
0 255 0 255
255 255 0 249.5744680851
0 0 0 96.8085493640
255 0 255 160.0370833175
3
255 0 0 174.0865384615
255 255 0 20.2133336297
255 0 255 31.3460966913
5
0 0 255 255
0 255 255 255
255 255 255 132.8125000000
0 0 255 5.8676276829
0 255 0 66.2463785719
5
0 0 255 255
0 255 255 255
255 255 255 138.9...

result:

ok ok (10000 test cases)

Test #8:

score: 0
Accepted
time: 20ms
memory: 3748kb

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:

5
0 0 255 255
0 255 255 255
255 255 255 178.1927710843
0 0 255 181.3395274033
0 255 0 66.8429087121
3
255 0 0 205.7586206897
255 255 0 35.5556488753
255 0 255 89.0006467100
5
0 0 255 255
0 255 255 255
255 255 255 119.4594594595
0 0 255 130.5946330913
0 0 0 55.7843840203
3
255 0 0 240.8333333333
255 ...

result:

ok ok (10000 test cases)

Test #9:

score: 0
Accepted
time: 20ms
memory: 3752kb

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:

4
0 255 0 255
255 255 0 210.4518072289
0 0 0 100.0219565836
255 255 255 19.1701564407
5
0 0 255 255
0 255 255 255
255 255 255 72.8571428571
0 0 255 213.6365580604
0 0 0 113.2469339786
5
0 0 255 255
0 255 255 255
255 255 255 4.0263157895
0 0 255 32.7563760194
0 255 0 37.3074195400
3
255 0 0 158.77358...

result:

ok ok (10000 test cases)

Test #10:

score: -100
Wrong Answer
time: 20ms
memory: 4008kb

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.4642857143
255 255 0 214.8085038403
255 255 255 92.3584469665
4
0 0 255 255
255 0 255 18.3233532934
255 255 255 58.8503181875
0 0 0 56.1441117406
4
0 0 255 255
255 0 255 174.7552447552
255 255 255 101.1196942606
255 0 0 27.1726086643
4
0 0 255 255
255 0 255 134.9206349206
255 255 255 2...

result:

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