# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
369340 | kostia244 | Art Class (IOI13_artclass) | C++17 | 96 ms | 16620 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;
}
ld uwu() {
ld sum = 0;
for(int i = 0; i+1 < n; i++)
for(int j = 0; j < m; j++)
sum += (img[i][j][1]-img[i+1][j][1])*(img[i][j][1]-img[i+1][j][1]);
for(int i = 0; i < n; i++)
for(int j = 0; j+1 < m; j++)
sum += (img[i][j][1]-img[i][j+1][1])*(img[i][j][1]-img[i][j+1][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 = uwu();
#define B aaa
const int A = 3;
const int B = 1;
const int C = 1;
vec r = {A*f, B*g, C*h};
pair<ld, int> ans = {1<<30, 0};
cout << f << " " << g << " " << h << endl;
vector<vec> a;
a.push_back({A* 11.171448888888888 ,B* 163.45119999999997 ,C* 285.9314333333333});//{10, 160, 290});
a.push_back({A* 19.13388888888889 ,B* 292.3247777777778 ,C* 264.59866666666665});//{17, 280, 210});
a.push_back({A* 50.98616666666666 ,B* 228.85688888888888 ,C* 1719.4388888888889});//{45, 280, 210});
a.push_back({A* 3.838406666666667 ,B* 288.8715555555556 ,C* 15.933765555555555});
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... |