QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#726020 | #6412. Classical Geometry Problem | KoalifiedKoalas# | WA | 16ms | 3912kb | C++14 | 2.2kb | 2024-11-08 21:16:53 | 2024-11-08 21:16:53 |
Judging History
answer
// Ilie "The-Winner" Dumitru
#include <bits/stdc++.h>
using ll = long long;
const int NMAX=4005;
const double EPS=1e-6;
const ll MOD=1000000007;
// Linux
#ifdef ONLINE_JUDGE
#define lld "%I64d"
#else
#define lld "%lld"
#endif
struct el
{
int r, g, b;
double d;
};
std::vector<el> sol;
void solve(double r, double g, double b)
{
if(fabs(r-g)<EPS && fabs(r-b)<EPS)
sol.push_back({255, 255, 255, sqrt(3)*r});
else
{
if(fabs(std::min(std::min(r, g), b))<EPS)
{
if(fabs(r)<EPS && fabs(g)<EPS)
sol.push_back({0, 0, 255, b});
else if(fabs(r)<EPS && fabs(b)<EPS)
sol.push_back({0, 255, 0, g});
else if(fabs(g)<EPS && fabs(b)<EPS)
sol.push_back({255, 0, 0, r});
else
{
double nr, ng, nb;
int mr=255, mg=255, mb=255;
if(fabs(r)<EPS)
{
nr=0;
mr=0;
if(g<b)
{
double s=(255-b)/(255-g);
nb=b-s*g;
ng=0;
}
else
{
double s=(255-g)/(255-b);
ng=g-s*b;
nb=0;
}
}
else if(fabs(g)<EPS)
{
ng=0;
mg=0;
if(r<b)
{
double s=(255-b)/(255-r);
nb=b-s*r;
nr=0;
}
else
{
double s=(255-r)/(255-b);
nr=r-s*b;
nb=0;
}
}
else
{
nb=0;
mb=0;
if(g<r)
{
double s=(255-r)/(255-g);
nr=r-s*g;
ng=0;
}
else
{
double s=(255-g)/(255-r);
ng=g-s*r;
nr=0;
}
}
solve(nr, ng, nb);
sol.push_back({mr, mg, mb, sqrt((nr-r)*(nr-r)+(ng-g)*(ng-g)+(nb-b)*(nb-b))});
}
}
else
{
double nr, ng, nb, c, min=std::min(r, std::min(g, b)), d;
c=min/(255-min);
nr=r-255;
ng=g-255;
nb=b-255;
d=sqrt(nr*nr+ng*ng+nb*nb);
nr=r+c*nr;
ng=g+c*ng;
nb=b+c*nb;
solve(nr, ng, nb);
sol.push_back({255, 255, 255, c*d});
}
}
}
void solve()
{
int r, g, b;
scanf("%d%d%d", &r, &g, &b);
sol.clear();
solve(r, g, b);
printf("%d\n", (int)sol.size());
for(el e : sol)
printf("%d %d %d %.9f\n", e.r, e.g, e.b, e.d);
}
int main()
{
int _=1;
scanf("%d", &_);
do solve(); while(--_);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3904kb
input:
3 105 255 175 174 174 174 0 0 0
output:
3 0 255 0 255.000000000 0 255 255 119.000000000 255 255 255 119.000000000 1 255 255 255 301.376840517 1 255 255 255 0.000000000
result:
ok ok (3 test cases)
Test #2:
score: 0
Accepted
time: 16ms
memory: 3912kb
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.683872524 3 0 255 0 244.920948617 0 255 255 1.004720917 255 255 255 1.411981405 3 0 255 0 98.076923077 0 255 255 89.645464492 255 255 255 113.949582887 3 0 0 255 50.328947368 255 0 255 193.374653314 255 255 255 77.897042765 3 0 255 0 232...
result:
ok ok (10000 test cases)
Test #3:
score: 0
Accepted
time: 16ms
memory: 3900kb
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.272727273 255 255 0 5.084891639 255 255 255 129.125162989 3 0 255 0 249.795918367 0 255 255 23.616027532 255 255 255 52.667780110 3 0 0 255 128.702830189 0 255 255 5.269681090 255 255 255 57.841219510 3 0 0 255 41.073825503 255 0 255 113.404792207 255 255 255 38.260031600 3 0 0 255 159...
result:
ok ok (10000 test cases)
Test #4:
score: -100
Wrong Answer
time: 16ms
memory: 3872kb
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.565217391 255 255 0 77.423738457 255 255 255 210.056622440 2 0 0 255 56.983240223 255 0 255 96.223583048 3 255 0 0 230.585106383 255 0 255 5.336794410 255 255 255 223.028684131 3 0 255 0 241.578947368 0 255 255 37.787654997 255 255 255 42.064428625 3 255 0 0 162.444444444 255 255 0 72....
result:
wrong output format Expected double, but "-nan" found (test case 9326)