QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#473011#6412. Classical Geometry ProblemUESTC_Snow_HalationWA 21ms3860kbC++172.3kb2024-07-11 20:58:092024-07-11 20:58:09

Judging History

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

  • [2024-07-11 20:58:09]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:3860kb
  • [2024-07-11 20:58:09]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
constexpr int max_n = 500;
double eps = 1e-8;

struct Color {
  double r, g, b;
  Color operator-(const Color& other) const { return {r - other.r, g - other.g, b - other.b}; }
  Color operator/(const double k) const { return {r / k, g / k, b / k}; }
  Color operator*(const double k) const { return {r * k, g * k, b * k}; }
  double len2() const { return r*r + g*g + b*b; }
  double len() const { return sqrt(len2()); }
};

vector<pair<array<int, 3>, double>> ans;

void solve() {
  ans.clear();
  Color target;
  cin >> target.r >> target.g >> target.b;
  int d[3] = {0, 1, 2};
  if (target.r > target.g) {
    swap(target.r, target.g);
    swap(d[0], d[1]);
  }
  if (target.r > target.b) {
    swap(target.r, target.b);
    swap(d[0], d[2]);
  }
  if (target.g > target.b) {
    swap(target.g, target.b);
    swap(d[1], d[2]);
  }
  Color v = Color{255, 255, 255} - target;
  if (target.r == 255) ans.emplace_back(array<int,3>{255,255,255},1000);
  else {
    Color nt = {0, 255 - v.g/v.r * 255, 255 - v.b/v.r * 255};
    ans.emplace_back(array<int,3>{255,255,255},(target - nt).len());
    target = nt;
  }
  if (target.g == 255) ans.emplace_back(array<int,3>{0, 255, 255}, 1000);
  else {
    Color nt = {0, 0, 255 - v.b/v.g * 255};
    ans.emplace_back(array<int,3>{0,255,255},(target - nt).len());
    target = nt;
  }
  if (target.b == 255) ans.emplace_back(array<int,3>{0, 0, 255}, 1000);
  else {
    Color nt = {0, 0, 0};
    ans.emplace_back(array<int,3>{0,0,255},(target - nt).len());
    target = nt;
  }
  int n = ans.size();
  cout << n << '\n';
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < 3; ++j) {
      cout << ans[i].first[d[j]] << ' ';
    }
    cout << setprecision(12) << ans[i].second << '\n';
  }
}

int main() {
//  freopen("code.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    cin >> T;
//    scanf("%d", &T);
    for (int i = 1; i <= T; ++i) {
        // cout << "Case " << i << ": ";
        solve();
    }
    return 0;
}

/*
3 3
2.4.2
.....
4.8.4
.....
2.5.3

5 5
3.4.4.4.2
.........
4.7.7.7.4
.........
4.8.7.7.4
.........
4.7.7.7.5
.........
2.4.4.4.2
*/

详细

Test #1:

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

input:

3
105 255 175
174 174 174
0 0 0

output:

3
0 255 0 1000
0 255 255 119
255 255 255 119
3
0 0 255 0
0 255 255 0
255 255 255 301.376840517
3
0 0 255 0
0 255 255 0
255 255 255 0

result:

ok ok (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 21ms
memory: 3860kb

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.960629921
255 255 0 121.271562482
255 255 255 14.6838725235
3
0 255 0 244.920948617
0 255 255 1.00472091733
255 255 255 1.41198140476
3
0 255 0 98.0769230769
0 255 255 89.6454644917
255 255 255 113.949582887
3
0 0 255 50.3289473684
255 0 255 193.374653314
255 255 255 77.8970427654
3
25...

result:

wrong answer too far from the target: (246.000000, 33.000000, 153.000000) instead of (153, 246, 33) (test case 5)