QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#472349#6412. Classical Geometry Problemlllei#WA 18ms3948kbC++202.9kb2024-07-11 15:49:082024-07-11 15:49:09

Judging History

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

  • [2024-07-11 15:49:09]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:3948kb
  • [2024-07-11 15:49:08]
  • 提交

answer

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

using A = array<double, 3>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin >> T;
    while (T--) {
        int x, y, z;
        cin >> x >> y >> z;

        auto len = [&](A a, A b) {
            return sqrt((a[0] - b[0]) * (a[0] - b[0]) + (a[1] - b[1]) * (a[1] - b[1]) + (a[2] - b[2]) * (a[2] - b[2]));
        };


        auto check = [&](int x) {
            return x == 255 || x == 0;
        };


        if (check(x) && check(y) && check(z)) {
            cout << 1 << '\n';
            cout << x << ' ' << y << ' ' << z << ' ';
            cout << fixed << setprecision(10) << len(A{x * 1.0, y * 1.0, z * 1.0}, A{0, 0, 0}) << '\n';
            continue;
        }
        A a0{x, y, z}, a1, a2;

        bool flag1 = 0, flag2 = 0;

        auto print = [&](A a) {
            if (flag1) {
                cout << (int)a[0] << ' ' << (int)a[2] << ' ' << (int)a[1];
            } else if (flag2) {
                cout << (int)a[2] << ' ' << (int)a[1] << ' ' << (int)a[0];
            } else {
                cout << (int)a[0] << ' ' << (int)a[1] << ' ' << (int)a[2];
            }
        };

        auto get1 = [&](A a) {
            double x = 255 - 255 * (255 - a[0]) / (255 - a[2]);
            double y = 255 - 255 * (255 - a[1]) / (255 - a[2]);
            return A{x, y, 0};
        };

        auto get2 = [&](A a) {
            double x = 255 - 255 * (255 - a[0]) /(255 - a[1]);
            return A{x, 0, 0};
        };

        auto get3 = [&](A a) {
            double y = 255 - 255 * (255 - a[1]) / (255 - a[0]);
            return A{0, y, 0};
        };

        auto print1 = [&](A a, A b) {
            cout << fixed << setprecision(10) << len(a, b);
        };

        a1 = get1(a0);

        if (a1[0] <= 255 && a1[0] >= 0 && a1[1] >= 0 && a1[1] <= 255) {

        } else {
            swap(a0[1], a0[2]);
            a1 = get1(a0);

            if (a1[0] <= 255 && a1[0] >= 0 && a1[1] >= 0 && a1[1] <= 255) {
                flag1 = 1;
            } else {
                swap(a0[1], a0[2]);
                swap(a0[0], a0[2]);
                a1 = get1(a0);
                flag2 = 1;
            }
        }

        a2 = get2(a1);

        bool flag3 = 0;
        if (a2[0] >= 0 && a2[0] <= 255) {
            
        } else {
            flag3 = true;
            a2 = get3(a1); 
        }

        cout << 3 << '\n';
        if (flag3) {
            print(A{0, 255, 0});
        } else {
            print(A{255, 0, 0});
        }
        cout << ' ';
        print1(a2, A{0, 0, 0});
        cout << '\n';

        print(A{255,255, 0});
        cout << ' ';
        print1(a2, a1);
        cout << '\n';

        print(A{255, 255, 255});
        cout << ' ';
        print1(a1, a0);
        cout << '\n';
    }
    return 0;
}

详细

Test #1:

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

input:

3
105 255 175
174 174 174
0 0 0

output:

3
0 255 0 255.0000000000
0 255 255 119.0000000000
255 255 255 119.0000000000
3
255 0 0 0.0000000000
255 255 0 0.0000000000
255 255 255 301.3768405170
1
0 0 0 0.0000000000

result:

ok ok (3 test cases)

Test #2:

score: 0
Accepted
time: 18ms
memory: 3940kb

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
3
0 255 0 244.9209486166
0 255 255 1.0047209173
255 255 255 1.4119814048
3
0 255 0 98.0769230769
0 255 255 89.6454644917
255 255 255 113.9495828874
3
0 0 255 50.3289473684
255 0 255 193.3746533137
255 255 255 77.8970427654
3...

result:

ok ok (10000 test cases)

Test #3:

score: 0
Accepted
time: 14ms
memory: 3948kb

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.2727272727
255 255 0 5.0848916386
255 255 255 129.1251629886
3
0 255 0 249.7959183673
0 255 255 23.6160275320
255 255 255 52.6677801101
3
0 0 255 128.7028301887
0 255 255 5.2696810897
255 255 255 57.8412195098
3
0 0 255 41.0738255034
255 0 255 113.4047922066
255 255 255 38.2600315997
3...

result:

ok ok (10000 test cases)

Test #4:

score: -100
Wrong Answer
time: 18ms
memory: 3748kb

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.5652173913
255 255 0 77.4237384566
255 255 255 210.0566224404
3
0 0 255 56.9832402235
255 0 255 96.2235830476
255 255 255 0.0000000000
3
255 0 0 230.5851063830
255 0 255 5.3367944104
255 255 255 223.0286841312
3
0 255 0 241.5789473684
0 255 255 37.7876549973
255 255 255 42.0644286252
3...

result:

wrong output format Expected double, but "-nan" found (test case 9326)