QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#114251#6412. Classical Geometry ProblemOepelingAC ✓80ms3836kbC++146.9kb2023-06-21 18:04:592023-06-21 18:05:02

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-21 18:05:02]
  • 评测
  • 测评结果:AC
  • 用时:80ms
  • 内存:3836kb
  • [2023-06-21 18:04:59]
  • 提交

answer

#include <iostream>
#include <tuple>
#include <vector>
#include <cassert>
#include <complex>
#include <cmath>
#include <iomanip>

#define EPS 1e-12

using namespace std;

template<class type>
using Point3d = tuple<type, type, type>;
using Point = complex<double>;

const double a = 255;
vector<Point3d<int>> corners;
Point3d<int> black = {0, 0, 0};

void insertCorners() {
	corners.emplace_back(0, 0, 0);
	corners.emplace_back(0, 0, a);
	corners.emplace_back(a, 0, a);
	corners.emplace_back(a, 0, 0);
	corners.emplace_back(0, a, a);
	corners.emplace_back(a, a, a);
	corners.emplace_back(a, a, 0);
	corners.emplace_back(0, a, 0);
}


int sign(double x) {
	if (x < -EPS) {
		return -1;
	} else if (x > EPS) {
		return 1;
	} else {
		return 0;
	}
}

Point3d<double> operator* (Point3d<double>& lhs, double rhs) {
	double x, y, z;
	tie(x, y, z) = lhs;
	return {x * rhs, y * rhs, z * rhs};
}

Point3d<double> operator- (Point3d<double>& lhs, Point3d<int>& rhs) {
	double x1, y1, z1; tie(x1, y1, z1) = lhs;
	double x2, y2, z2; tie(x2, y2, z2) = rhs;
	return {x1 - x2, y1 - y2, z1 - z2};
}

double dist(Point3d<double> lhs, Point3d<double> rhs) {
	double x1, y1, z1; tie(x1, y1, z1) = lhs;
	double x2, y2, z2; tie(x2, y2, z2) = rhs;
	x2 -= x1; y2 -= y1; z2 -= z1;
	return sqrt(x2 * x2 + y2 * y2 + z2 * z2);
}

bool OnSegment(Point3d<double>& p1, Point3d<double>& p2, Point3d<double>& p) {
	return (sign(dist(p1, p) + dist(p2, p) - dist(p1, p2)) == 0);
}

bool OnSegment(Point3d<int>& lhs, Point3d<int>& rhs, Point3d<double>& p) {
	double x1, y1, z1; tie(x1, y1, z1) = lhs;
	Point3d<double> p1 = {x1, y1, z1};

	double x2, y2, z2; tie(x2, y2, z2) = rhs;
	Point3d<double> p2 = {x2, y2, z2};

	return OnSegment(p1, p2, p);
}

double cross(Point a, Point b) {
	return a.real() * b.imag() - a.imag() * b.real();
}

double det(Point a, Point b, Point c) {
	return cross(b - a, c - a);
}

double dot(Point a, Point b) {
	return a.real() * b.real() + a.imag() * b.imag();
}

bool OnSegment(Point s, Point e, Point p) {
	return sign(det(p, s, e)) == 0 && sign(dot(s - p, e - p)) <= 0;
}

int InsidePoligon(vector<Point>& P, const Point& p) {
	int ic = 0, n = P.size();
	for (int i = 0, j = n - 1; i < n; j = i++) {
		if (OnSegment(P[i], P[j], p)) return 0;
		ic += (max(P[i].imag(), P[j].imag()) > p.imag() &&
			min(P[i].imag(), P[j].imag()) <= p.imag() &&
			(det(P[i], P[j], p) > 0) == (P[i].imag() <= p.imag()));
	}
	return ic % 2 ? 1 : -1;
}

Point LineIntersection(Point a, Point b, Point p, Point q) {
	double c1 = det(a, b, p);
	double c2 = det(a, b, q);
	assert(sign(c1 - c2));
	return (q * c1 - p * c2) / (c1 - c2);
}

bool isBlack(const Point3d<double>& p) {
	return (sign(get<0>(p)) == 0 && sign(get<1>(p)) == 0 && sign(get<2>(p)) == 0);
}

bool isPoint(Point3d<double> p) {
	for (auto c : corners) {
		bool ok = true;
		if (sign(get<0>(p) - get<0>(c)) == 0
			&& sign(get<1>(p) - get<1>(c)) == 0
			&& sign(get<2>(p) - get<2>(c)) == 0) {
			return true;
		}
	}
	return false;
}

bool isLatura(Point3d<double> p) {
	for (int i = 0; i < corners.size(); i++) {
		for (int j = 0; j < corners.size(); j++) {
			if (i == j) { continue; }
			if (OnSegment(corners[i], corners[j], p)) {
				return true;
			}
		}
	}
	return false;
}

void SolvePoint(Point3d<double>& p1, vector<pair<Point3d<int>, double>>& ans) {
	for (int i = 0; i < corners.size(); i++) {
		if (isBlack(p1 - corners[i])) {
			ans.emplace_back(corners[i], 3 * a);
			return;
		}
	}
}

void SolveLatura(Point3d<double>& p1, vector<pair<Point3d<int>, double>>& ans) {
	for (int i = 0; i < corners.size(); i++) {
		for (int j = 0; j < corners.size(); j++) {
			if (i == j) { continue; }
			if (OnSegment(corners[i], corners[j], p1)) {
				ans.emplace_back(corners[i], 3 * a);
				ans.emplace_back(corners[j], dist(corners[i], p1));
				return;
			}
		}
	}
}

void PrintPoint(Point p) {
	cerr << "!! " << p.real() << " " << p.imag() << endl;
}

void PrintPoint(Point3d<double> p) {
	double x, y, z; tie(x, y, z) = p;
	cerr << fixed << setprecision(3) << x << " " << y << " " << z << endl;
}

void SolveFataKnown(Point p, vector<int>& id, vector<Point>& p2d, vector<pair<Point3d<int>, double>>& ans) {
	ans.emplace_back(corners[id[0]], 3 * a);
	auto aux = p2d;
	aux.pop_back();
	Point p2;

	// PrintPoint(p);
	
	if (InsidePoligon(aux, p) != -1) {
		// PrintPoint(p2d[2]);
		// PrintPoint(p2d[0]);
		// PrintPoint(p2d[1]);

		p2 = LineIntersection(p, p2d[2], p2d[0], p2d[1]);
		// PrintPoint(p2);
		// PrintPoint(p);
		// PrintPoint(p2d[2]);
		// PrintPoint(p2d[0]);
		// PrintPoint(p2d[1]);

		ans.emplace_back(corners[id[1]], abs(p2 - p2d[0]));
		ans.emplace_back(corners[id[2]], abs(p2 - p));
	} else {
		p2 = LineIntersection(p, p2d[2], p2d[0], p2d[3]);
		// PrintPoint(p2);
		// PrintPoint(p);
		// PrintPoint(p2d[2]);
		// PrintPoint(p2d[0]);
		// PrintPoint(p2d[1]);

		ans.emplace_back(corners[id[3]], abs(p2 - p2d[0]));
		ans.emplace_back(corners[id[2]], abs(p2 - p));
	}
}

void SolveFata(Point3d<double>& p1, vector<pair<Point3d<int>, double>>& ans) {
	int face = -1;
	if (sign(get<0>(p1) - a) == 0) {
		face = 0;
	} else if (sign(get<1>(p1) - a) == 0) {
		face = 1;
	} else if (sign(get<2>(p1) - a) == 0) {
		face = 2;
	}
	assert(face != -1);
	
	Point p;
	vector<int> face_id;
	vector<Point> face_2d;
	if (face == 0) {
		p = {get<1>(p1), get<2>(p1)};
		face_id = {2, 3, 6, 5};
		for (auto i : face_id) {
			face_2d.emplace_back(get<1>(corners[i]), get<2>(corners[i]));
		}
	} else if (face == 1) {
		p = {get<0>(p1), get<2>(p1)};
		face_id = {7, 4, 5, 6};
		for (auto i : face_id) {
			face_2d.emplace_back(get<0>(corners[i]), get<2>(corners[i]));
		}
	} else {
		p = {get<0>(p1), get<1>(p1)};
		face_id = {1, 2, 5, 4};
		for (auto i : face_id) {
			face_2d.emplace_back(get<0>(corners[i]), get<1>(corners[i]));
		}
	}

	SolveFataKnown(p, face_id, face_2d, ans);
}

vector<pair<Point3d<int>, double>> Solve(double x, double y, double z) {
	Point3d<double> p = {x, y, z};

	if (isBlack(p)) {
		return vector<pair<Point3d<int>, double>>();
	}

	double sigma = a / max(max(x, y), z);
	Point3d<double> p1 = p * sigma;

	vector<pair<Point3d<int>, double>> ans;

	if (isPoint(p1)) {
		SolvePoint(p1, ans);
	} else if (isLatura(p1)) {
		SolveLatura(p1, ans);
	} else {
		SolveFata(p1, ans);
	}

	// PrintPoint(p);
	ans.emplace_back(black, dist(p1, p));

	assert(ans.size() <= 10);
	return ans;
}

int main() {
	insertCorners();

	int t; cin >> t;
	for (int i = 0; i < t; i++) {
		double x, y, z; cin >> x >> y >> z;

		auto ans = Solve(x, y, z);
		
		// cerr << endl;
		cout << ans.size() << "\n";
		for (int i = 0; i < ans.size(); i++) {
			int x, y, z;
			tie(x, y, z) = ans[i].first;
			cout << x << " " << y << " " << z << " " << fixed << setprecision(8) << ans[i].second << "\n";
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3756kb

input:

3
105 255 175
174 174 174
0 0 0

output:

4
0 255 0 765.00000000
0 255 255 119.00000000
255 255 255 119.00000000
0 0 0 0.00000000
2
255 255 255 765.00000000
0 0 0 140.29611541
0

result:

ok ok (3 test cases)

Test #2:

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

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:

4
255 0 255 765.00000000
255 0 0 227.82786885
255 255 0 131.29912792
0 0 0 5.62327307
4
0 255 0 765.00000000
0 255 255 1.04508197
255 255 255 1.46892340
0 0 0 10.00041648
4
0 255 0 765.00000000
0 255 255 134.21052632
255 255 255 135.68420569
0 0 0 96.59557262
4
0 0 255 765.00000000
255 0 255 224.400...

result:

ok ok (10000 test cases)

Test #3:

score: 0
Accepted
time: 61ms
memory: 3656kb

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:

4
0 255 0 765.00000000
255 255 0 8.89534884
255 255 255 178.21940977
0 0 0 101.21401346
4
0 255 0 765.00000000
0 255 255 24.05660377
255 255 255 53.45558575
0 0 0 4.15575854
4
0 0 255 765.00000000
0 255 255 9.18918919
255 255 255 92.08844520
0 0 0 112.58907585
4
0 0 255 765.00000000
255 0 255 194.40...

result:

ok ok (10000 test cases)

Test #4:

score: 0
Accepted
time: 41ms
memory: 3744kb

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 255 0 765.00000000
255 255 0 113.83928571
255 255 255 216.24759074
0 0 0 57.44366048
3
0 0 255 765.00000000
255 0 255 167.06896552
0 0 0 166.17628134
4
255 0 255 765.00000000
255 255 255 117.20496894
255 255 0 100.15109380
0 0 0 12.22838148
4
0 255 0 765.00000000
0 255 255 39.50704225
255 255 25...

result:

ok ok (10000 test cases)

Test #5:

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

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 765.00000000
255 0 255 22.36842105
255 255 255 8.85051738
0 0 0 21.13609201
4
0 0 255 765.00000000
255 0 255 165.90361446
255 255 255 9.42268425
0 0 0 99.61758002
4
255 0 255 765.00000000
255 0 0 8.54748603
255 255 0 34.03034157
0 0 0 75.88978464
4
255 0 255 765.00000000
255 0 0 229.500000...

result:

ok ok (10000 test cases)

Test #6:

score: 0
Accepted
time: 38ms
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:

4
255 0 255 765.00000000
255 0 0 70.83333333
255 255 0 128.91436349
0 0 0 154.51126927
4
0 0 255 765.00000000
255 0 255 164.51612903
255 255 255 14.17874790
0 0 0 31.23591622
4
0 0 255 765.00000000
255 0 255 72.85714286
255 255 255 229.91851500
0 0 0 105.16768639
4
0 0 255 765.00000000
0 255 255 115...

result:

ok ok (10000 test cases)

Test #7:

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

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
255 0 255 765.00000000
255 255 255 4.04761905
255 255 0 150.98711152
0 0 0 45.61651206
4
255 0 255 765.00000000
255 0 0 210.52325581
255 255 0 23.28277961
0 0 0 67.08943802
4
0 255 0 765.00000000
0 255 255 162.11920530
255 255 255 108.12299945
0 0 0 5.31939205
4
0 0 255 765.00000000
0 255 255 234....

result:

ok ok (10000 test cases)

Test #8:

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

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 765.00000000
0 255 255 146.48936170
255 255 255 80.77078043
0 0 0 70.23121331
4
255 0 255 765.00000000
255 0 0 146.25000000
255 255 0 28.08848592
0 0 0 30.11990889
4
0 0 255 765.00000000
0 255 255 97.06451613
255 255 255 75.34917830
0 0 0 55.78438402
4
255 0 255 765.00000000
255 0 0 156.68...

result:

ok ok (10000 test cases)

Test #9:

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

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 765.00000000
255 255 0 210.45180723
255 255 255 24.04729077
0 0 0 94.33930425
4
0 0 255 765.00000000
0 255 255 37.50000000
255 255 255 18.61991914
0 0 0 113.24693398
4
0 255 0 765.00000000
0 255 255 244.75446429
255 255 255 3.37276312
0 0 0 38.82269858
3
255 0 0 765.00000000
255 255 0 62.6...

result:

ok ok (10000 test cases)

Test #10:

score: 0
Accepted
time: 58ms
memory: 3696kb

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:

4
255 0 255 765.00000000
255 255 255 190.54945055
255 255 0 167.27993766
0 0 0 6.99456932
4
0 0 255 765.00000000
255 0 255 18.32335329
255 255 255 58.85031819
0 0 0 56.14411174
4
0 0 255 765.00000000
255 0 255 219.33566434
255 255 255 97.39533915
0 0 0 35.14905474
4
0 0 255 765.00000000
255 0 255 13...

result:

ok ok (10000 test cases)

Test #11:

score: 0
Accepted
time: 43ms
memory: 3640kb

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
255 0 255 765.00000000
255 255 255 123.90845070
255 255 0 90.97936674
0 0 0 64.56848490
3
255 0 255 765.00000000
255 255 255 175.82661290
0 0 0 11.01345505
4
255 0 255 765.00000000
255 0 0 170.87628866
255 255 0 107.73861591
0 0 0 101.87671919
4
0 255 0 765.00000000
0 255 255 90.00000000
255 255 2...

result:

ok ok (10000 test cases)

Test #12:

score: 0
Accepted
time: 46ms
memory: 3656kb

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:

4
0 255 0 765.00000000
255 255 0 194.49152542
255 255 255 145.81931793
0 0 0 177.22048288
4
0 0 255 765.00000000
0 255 255 213.13432836
255 255 255 110.43328295
0 0 0 195.32891729
4
0 255 0 765.00000000
0 255 255 61.97916667
255 255 255 92.95134297
0 0 0 59.26382805
4
0 255 0 765.00000000
0 255 255 ...

result:

ok ok (10000 test cases)

Test #13:

score: 0
Accepted
time: 31ms
memory: 3736kb

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 765.00000000
255 0 255 133.20895522
255 255 255 120.76567596
0 0 0 27.46447110
4
0 255 0 765.00000000
255 255 0 8.46473029
255 255 255 16.82321724
0 0 0 2.00848082
4
255 0 255 765.00000000
255 0 0 5.42553191
255 255 0 287.79628008
0 0 0 15.58343572
4
0 0 255 765.00000000
255 0 255 185.2358...

result:

ok ok (10000 test cases)

Test #14:

score: 0
Accepted
time: 42ms
memory: 3836kb

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 765.00000000
0 255 255 218.36206897
255 255 255 71.62010598
0 0 0 19.19879661
4
0 0 255 765.00000000
0 255 255 28.09322034
255 255 255 19.11493263
0 0 0 5.07133119
4
0 0 255 765.00000000
0 255 255 249.65968586
255 255 255 32.60988847
0 0 0 50.65841587
4
0 255 0 765.00000000
255 255 0 80.75...

result:

ok ok (10000 test cases)

Test #15:

score: 0
Accepted
time: 56ms
memory: 3740kb

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
255 0 255 765.00000000
255 255 255 247.03125000
255 255 0 28.34716459
0 0 0 4.96165855
4
0 255 0 765.00000000
0 255 255 7.63473054
255 255 255 8.31033705
0 0 0 84.13920957
4
255 0 255 765.00000000
255 255 255 193.70192308
255 255 0 34.96854567
0 0 0 23.13040477
4
0 0 255 765.00000000
255 0 255 57....

result:

ok ok (10000 test cases)

Test #16:

score: 0
Accepted
time: 59ms
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 765.00000000
255 0 255 3.28326180
255 255 255 10.45071892
0 0 0 15.01938851
4
0 255 0 765.00000000
255 255 0 184.16666667
255 255 255 189.03940998
0 0 0 4.60651220
4
0 255 0 765.00000000
0 255 255 7.77439024
255 255 255 10.50797872
0 0 0 86.18798823
4
0 255 0 765.00000000
0 255 255 32.6923...

result:

ok ok (10000 test cases)

Test #17:

score: 0
Accepted
time: 57ms
memory: 3836kb

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:

3
0 0 255 765.00000000
0 255 255 3.01181102
0 0 0 1.00006975
4
255 0 255 765.00000000
255 0 0 191.25000000
255 255 0 29.20533151
0 0 0 253.47890554
3
255 255 0 765.00000000
0 255 0 4.01574803
0 0 0 1.40312221
4
0 0 255 765.00000000
255 0 255 11.95312500
255 255 255 5.41959590
0 0 0 190.38186478
4
0 ...

result:

ok ok (10000 test cases)

Test #18:

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

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:

3
0 0 255 765.00000000
0 255 255 253.00000000
0 0 0 0.00000000
4
255 0 255 765.00000000
255 0 0 85.00000000
255 255 0 302.86630714
0 0 0 0.00000000
2
255 0 255 765.00000000
0 0 0 0.00000000
4
0 0 255 765.00000000
0 255 255 153.00000000
255 255 255 269.25824036
0 0 0 0.00000000
3
0 0 255 765.00000000...

result:

ok ok (10000 test cases)

Test #19:

score: 0
Accepted
time: 51ms
memory: 3740kb

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:

0
2
255 0 255 765.00000000
0 0 0 0.00000000
2
0 255 255 765.00000000
0 0 0 0.00000000
3
255 255 255 765.00000000
255 255 0 254.00000000
0 0 0 0.00000000
0
3
0 255 255 765.00000000
0 255 0 254.00000000
0 0 0 0.00000000
3
255 0 255 765.00000000
255 0 0 1.00000000
0 0 0 0.00000000
2
0 255 0 765.0000000...

result:

ok ok (10000 test cases)

Test #20:

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

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:

0
2
0 255 255 765.00000000
0 0 0 0.00000000
2
255 0 255 765.00000000
0 0 0 0.00000000
2
255 255 0 765.00000000
0 0 0 0.00000000
2
255 255 255 765.00000000
0 0 0 0.00000000
2
255 0 0 765.00000000
0 0 0 0.00000000
2
255 255 255 765.00000000
0 0 0 0.00000000
2
0 0 255 765.00000000
0 0 0 0.00000000
0
2
...

result:

ok ok (10000 test cases)