QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#154245#6412. Classical Geometry ProblemPhantomThreshold#WA 201ms3848kbC++202.1kb2023-08-31 15:39:472023-08-31 15:39:48

Judging History

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

  • [2023-08-31 15:39:48]
  • 评测
  • 测评结果:WA
  • 用时:201ms
  • 内存:3848kb
  • [2023-08-31 15:39:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long double db;
const db eps=1e-10;
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;	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3716kb

input:

3
105 255 175
174 174 174
0 0 0

output:

3
0 255 0 1000.000000000000
0 255 255 119.000000000047
255 255 255 119.000000000113
1
255 255 255 301.376840517158
0

result:

ok ok (3 test cases)

Test #2:

score: 0
Accepted
time: 86ms
memory: 3848kb

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.960629921356
255 255 0 121.271562481755
255 255 255 14.683872523647
3
0 255 0 244.920948616697
0 255 255 1.004720917329
255 255 255 1.411981404899
3
0 255 0 98.076923076962
0 255 255 89.645464491763
255 255 255 113.949582887516
3
0 0 255 50.328947368441
255 0 255 193.374653313733
255 2...

result:

ok ok (10000 test cases)

Test #3:

score: 0
Accepted
time: 79ms
memory: 3728kb

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
0 255 0 128.272727272778
255 255 0 5.084891638577
255 255 255 129.125162988765
3
0 255 0 249.795918367445
0 255 255 23.616027532019
255 255 255 52.667780110259
3
0 0 255 128.702830188730
0 255 255 5.269681089671
255 255 255 57.841219509964
3
0 0 255 41.073825503372
255 0 255 113.404792206684
255 2...

result:

ok ok (10000 test cases)

Test #4:

score: 0
Accepted
time: 75ms
memory: 3680kb

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:

3
0 255 0 114.565217391349
255 255 0 77.423738456607
255 255 255 210.056622440497
2
0 0 255 56.983240223486
255 0 255 96.223583047742
3
255 0 0 230.585106383069
255 0 255 5.336794410426
255 255 255 223.028684131380
3
0 255 0 241.578947368516
0 255 255 37.787654997314
255 255 255 42.064428625315
3
25...

result:

ok ok (10000 test cases)

Test #5:

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

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:

3
0 0 255 231.615720524108
255 0 255 20.567868290699
255 255 255 8.167324052387
3
0 0 255 104.893617021318
255 0 255 128.342253846657
255 255 255 7.179388571871
3
255 0 0 77.743902439055
255 0 255 202.650628704200
255 255 255 20.631072226124
3
255 0 0 50.000000000020
255 255 0 261.490344428727
255 2...

result:

ok ok (10000 test cases)

Test #6:

score: 0
Accepted
time: 71ms
memory: 3644kb

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 87.931034482793
255 0 255 2.974202613933
255 255 255 77.483854893836
3
0 0 255 190.631067961240
255 0 255 151.521932102323
255 255 255 13.096571883324
3
0 0 255 84.198113207580
255 0 255 35.807028880378
255 255 255 197.042071967023
3
0 0 255 81.263736263768
0 255 255 64.395135756708
255 25...

result:

ok ok (10000 test cases)

Test #7:

score: 0
Accepted
time: 66ms
memory: 3712kb

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
255 0 0 181.860465116350
255 0 255 52.726801714293
255 255 255 122.373539650932
3
255 0 0 180.200000000071
255 0 255 14.515445679188
255 255 255 23.864519817695
3
0 255 0 237.711864406873
0 255 255 158.298033521981
255 255 255 107.030683066160
3
0 0 255 9.659090909095
0 255 255 105.405216687126
25...

result:

ok ok (10000 test cases)

Test #8:

score: 0
Accepted
time: 79ms
memory: 3720kb

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:

3
0 0 255 131.896551724190
0 255 255 116.426100961117
255 255 255 69.297979045439
3
255 0 0 212.500000000083
255 0 255 71.315146906973
255 255 255 28.532440806320
3
0 0 255 170.000000000067
0 255 255 78.122278156407
255 255 255 64.929265791176
3
255 0 0 246.104651162887
255 255 0 25.381921366384
255...

result:

ok ok (10000 test cases)

Test #9:

score: 0
Accepted
time: 69ms
memory: 3632kb

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.217821782207
255 255 0 180.264897951383
255 255 255 19.170156440768
3
0 0 255 130.308370044104
0 255 255 22.984116613223
255 255 255 11.444661707585
3
0 255 0 62.027027027051
0 255 255 272.833937296949
255 255 255 3.050431180359
2
255 0 0 158.773584905723
255 255 0 45.959727445054
3
255...

result:

ok ok (10000 test cases)

Test #10:

score: 0
Accepted
time: 54ms
memory: 3648kb

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.464285714368
255 255 0 214.808503840420
255 255 255 92.358446966559
3
0 0 255 189.114832535959
255 0 255 14.300849793853
255 255 255 47.527755827282
3
0 0 255 113.333333333378
255 0 255 213.573041912820
255 255 255 90.992672529719
3
0 0 255 148.333333333392
255 0 255 109.253171541418
2...

result:

ok ok (10000 test cases)

Test #11:

score: 0
Accepted
time: 94ms
memory: 3820kb

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:

3
255 0 0 148.938053097404
255 0 255 16.110367375590
255 255 255 192.825131271977
2
255 0 255 330.572420204841
255 255 255 172.183405123823
3
255 0 0 130.184210526367
255 255 0 42.013351118675
255 255 255 44.107298711279
3
0 255 0 131.484375000052
0 255 255 62.196412608108
255 255 255 11.91296141253...

result:

ok ok (10000 test cases)

Test #12:

score: 0
Accepted
time: 83ms
memory: 3680kb

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
0 255 0 26.250000000010
255 255 0 85.168378155683
255 255 255 105.144975287939
3
0 0 255 18.825503355712
0 255 255 94.945357029963
255 255 255 70.381809071701
3
0 255 0 172.639751552863
0 255 255 47.851882214977
255 255 255 77.941037429034
3
0 255 0 121.229508196769
0 255 255 191.971692910244
255 ...

result:

ok ok (10000 test cases)

Test #13:

score: 0
Accepted
time: 96ms
memory: 3704kb

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:

3
0 0 255 192.000000000075
255 0 255 118.623846951478
255 255 255 114.851394732649
3
0 255 0 252.829787234142
255 255 0 8.395365754101
255 255 255 16.693841586135
3
255 0 0 203.135593220419
255 255 0 186.761411336869
255 255 255 47.870686905288
3
0 0 255 150.918367346998
255 0 255 168.314230094533
2...

result:

ok ok (10000 test cases)

Test #14:

score: 0
Accepted
time: 82ms
memory: 3840kb

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:

3
0 0 255 163.461538461603
0 255 255 214.728227972547
255 255 255 68.608120196318
3
0 0 255 249.069767441958
0 255 255 27.517811695703
255 255 255 18.763665325634
3
0 0 255 25.500000000010
0 255 255 282.615005588089
255 255 255 28.776064152003
3
0 255 0 190.090909090984
255 255 0 67.560792389850
255...

result:

ok ok (10000 test cases)

Test #15:

score: 0
Accepted
time: 118ms
memory: 3840kb

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:

3
255 0 0 178.500000000070
255 255 0 180.347875339477
255 255 255 236.362303249804
3
0 255 0 167.926829268359
0 255 255 5.367656836773
255 255 255 5.758547600223
3
255 0 0 173.617021276664
255 0 255 74.124496760051
255 255 255 238.530957637660
3
0 0 255 253.629032258164
255 0 255 57.375829208391
255...

result:

ok ok (10000 test cases)

Test #16:

score: -100
Wrong Answer
time: 201ms
memory: 3752kb

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:

3
0 0 255 239.387755102135
255 0 255 3.090453372978
255 255 255 9.848905676818
3
0 255 0 221.739130434870
255 255 0 178.297626751252
255 255 255 188.411464619432
3
0 255 0 165.489795918432
0 255 255 5.405074528063
255 255 255 7.208911152322
3
0 255 0 34.819277108447
0 255 255 6.631975676621
255 255 ...

result:

wrong answer too far from the target: (255.000000, 255.000000, 0.000000) instead of (251, 1, 251) (test case 5179)