# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1075574 | TheQuantiX | Art Class (IOI13_artclass) | C++17 | 0 ms | 0 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 <bits/stdc++.h>
using namespace std;
vector<float> vecs[4] = {{0.707344, 0.363771, 0.543803}, {0.994021, 0.989584, 0.00129563}, {1.02652, 0.767299, 0.00728856}, {0.995276, 0.500576, 0.0165025}};
vector<float> vectorize(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
vector<float> ans;
float r = 0, g = 0, b = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
r += R[i][j] * 3 / (R[i][j] + G[i][j] + B[i][j]);
g += G[i][j] * 3 / (R[i][j] + G[i][j] + B[i][j]);
b += B[i][j] * 3 / (R[i][j] + G[i][j] + B[i][j]);
}
}
r /= H * W;
g /= H * W;
b /= H * W;
ans.push_back(r);
ans.push_back(g);
ans.push_back(b);
return ans;
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
auto fl = vectorize(H, W, R, G, B);
array<float, 4> diffsq = {0, 0, 0, 0};
for (int i = 0; i < 4; i++) {
for (int j = 0; j < fl.size(); j++) {
diffsq[i] += (fl[j] - vecs[i][j]) * (fl[j] - vecs[i][j]);
}
}
return min_element(diffsq.begin(), diffsq.end()) - diffsq.begin() + 1;
}