# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076123 | TheQuantiX | 미술 수업 (IOI13_artclass) | C++17 | 53 ms | 3416 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>
#include "artclass.h"
using namespace std;
vector<float> vecs[4] = {{0.172865}, {0.344829}, {0.536416}, {0.0900339}};
vector<float> vectorize(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
vector<float> ans;
// double r = 0, g = 0, b = 0;
// double cntgrey = 0;
// for (int i = 0; i < H; i++) {
// for (int j = 0; j < W; j++) {
// // if ((R[i][j] + G[i][j] + B[i][j]) == 0) {
// // continue;
// // }
// r += R[i][j] / 255.;
// g += G[i][j] / 255.;
// b += B[i][j] / 255.;
// // r += (float)R[i][j] * 3. / (R[i][j] + G[i][j] + B[i][j]);
// // g += (255 * 2 + (float)G[i][j] * 2. - R[i][j] - B[i][j]) / (255. * 4);
// // b += (float)B[i][j] * 3. / (R[i][j] + G[i][j] + B[i][j]);
// }
// }
// for (int i = 0; i < H; i++) {
// for (int j = 0; j < W; j++) {
// if (max({R[i][j], G[i][j], B[i][j]}) - min({R[i][j], G[i][j], B[i][j]}) <= 20) {
// cntgrey++;
// }
// }
// }
// ans.push_back(cntgrey / (H * W));
// // cout << cntgrey / (H * W) << '\n';
// // r /= H * W;
// // g /= H * W;
// // b /= H * W;
// // ans.push_back(r);
// // cout << r << ' ' << g << ' ' << b << '\n';
// ans.push_back(abs(r - b) / (H * W));
// ans.push_back(abs(g - b) / (H * W));
// ans.push_back((g - r - b) / (H * W));
// ans.push_back(b);
float d = 0;
for (int i = 0; i < H - 1; i++) {
for (int j = 0; j < W; j++) {
// if ((R[i][j] + G[i][j] + B[i][j]) == 0) {
// continue;
// }
d += abs(R[i + 1][j] - R[i][j]) / 255.;
d += abs(G[i + 1][j] - G[i][j]) / 255.;
d += abs(B[i + 1][j] - B[i][j]) / 255.;
}
}
// cout << d << endl;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W - 1; j++) {
// if ((R[i][j] + G[i][j] + B[i][j]) == 0) {
// continue;
// }
d += abs(R[i][j + 1] - R[i][j]) / 255.;
d += abs(G[i][j + 1] - G[i][j]) / 255.;
d += abs(B[i][j + 1] - B[i][j]) / 255.;
}
}
d /= H * W * 2;
// cout << '\t' << d << endl;
ans.push_back(d);
// float eq = 0;
// for (int i = 0; i < H; i++) {
// for (int j = 0; j < W; j++) {
// // if ((R[i][j] + G[i][j] + B[i][j]) == 0) {
// // continue;
// // }
// eq += (255. + R[i][j] - B[i][j]) / (255. * 2);
// }
// }
// // cout << d << endl;
// eq /= H * W;
// ans.push_back(eq);
// float e = 1;
// for (int i = 0; i < ans.size(); i++) {
// e *= ans[i];
// }
// e = sqrt(sqrt(e));
// for (int i = 0; i < ans.size(); i++) {
// ans[i] /= e;
// }
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 = {1, 1, 1, 1};
for (int i = 0; i < 4; i++) {
for (int j = 0; j < fl.size(); j++) {
diffsq[i] *= (fl[j] / vecs[i][j] < 1 ? vecs[i][j] / fl[j] : fl[j] / vecs[i][j]);
}
}
return min_element(diffsq.begin(), diffsq.end()) - diffsq.begin() + 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |