# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
369337 | kostia244 | Art Class (IOI13_artclass) | C++17 | 114 ms | 17772 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "artclass.h"
#include<bits/stdc++.h>
using namespace std;
using ld = long double;
const int maxn = 500;
using vec = array<ld, 3>;
const vec green = {0, 255, 0};
const vec white = {255, 255, 255};
ld dif(vec a, vec b) {
ld t = 0;
for(int i = 0; i < 3; i++)
t += (a[i]-b[i])*(a[i]-b[i]);
return sqrt(t);
}
int n, m;
vec img[maxn][maxn];
ld compare(vec col) {
ld sum = 0;
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
sum += dif(img[i][j], col);
return sum / (n*m);
}
ld sharpness() {
ld sum = 0;
for(int i = 0; i+1 < n; i++)
for(int j = 0; j < m; j++)
sum += dif(img[i][j], img[i+1][j]);
for(int i = 0; i < n; i++)
for(int j = 0; j+1 < m; j++)
sum += dif(img[i][j], img[i][j+1]);
sum /= n*(m-1) + (n-1)*m;
return sum;
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
n = H, m = W;
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++) {
img[i][j] = {R[i][j],G[i][j],B[i][j]};
}
ld f = sharpness();
ld g = compare(white);
ld h = compare(green);
#define B aaa
const int A = 10;
const int B = 5;
const int C = 2;
vec r = {A*f, B*g, C*h};
pair<ld, int> ans = {1<<30, 0};
vector<vec> a;
a.push_back({A*11.171448888888888, B*163.45119999999997, C*294.5782222222222});//{10, 160, 290});
a.push_back({A*19.13388888888889, B*292.3247777777778, C*217.07022222222224});//{17, 280, 210});
a.push_back({A*50.98616666666666, B*228.85688888888888, C*242.315});//{45, 280, 210});
a.push_back({A*3.838406666666667, B*288.8715555555556, C*258.89955555555554});
for(int i = 0; i < 4; i++)
ans = min(ans, {dif(a[i], r), i+1});
return ans.second;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |