# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72570 | RezwanArefin01 | Art Class (IOI13_artclass) | C++17 | 5103 ms | 66560 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;
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, -1, 1, 1, -1};
struct point {
int r, g, b;
point(int _r = 0, int _g = 0, int _b = 0) :
r(_r), g(_g), b(_b) {}
} p[500][500];
int n, m;
int sq(int x) { return x * x; }
double dist(point a, point b) {
return sqrt(sq(a.r - b.r) + sq(a.b - b.b) + sq(a.g - b.g));
}
double get_noise() {
int cnt = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
int diff = 0;
for(int k = 0; k < 8; k++) {
int ii = i + dx[k], jj = j + dy[k];
if(ii >= 0 && ii < n && jj >= 0 && jj < m)
if(dist(p[i][j], p[ii][jj]) > 10) diff++;
} if(diff >= 5) cnt++;
}
}
return (double) cnt / (n * m);
}
double get_close(vector<point> q) {
double ret = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
double x = 100000;
for(int k = 0; k < q.size(); k++) {
x = min(x, dist(p[i][j], q[k]));
} ret += x;
}
}
return ret / (n * m);
}
bool vis[500][500];
void fill(int x, int y) {
memset(vis, 0, sizeof vis);
vis[x][y] = 1;
for(int i = 0; i < 4; i++) {
int xx = x + dx[i], yy = y + dy[i];
if(xx >= 0 && xx < n && yy >= 0 && yy < m && !vis[xx][yy])
if(dist(p[x][y], p[xx][yy]) <= 15) fill(xx, yy);
}
}
int get_comp() {
int ret = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) if(!vis[i][j]) {
++ret; fill(i, j);
}
} return ret;
}
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++) {
p[i][j] = point{R[i][j], G[i][j], B[i][j]};
}
}
double noise = get_noise();
double green = get_close({{198, 201, 220}, {98, 38, 28}, {234, 152, 131},{68, 71, 26},
{40, 40, 40}, {29, 39, 12}, {21, 77, 48}, {40, 27, 19}});
double tile = get_close({{255,255,0}, {255,0,0}, {255,255,255}, {0,0,0}, {0,0,255},
{179,184,204}, {218, 164, 6}, {173, 195, 216}});
double comp = get_comp();
if(comp <= 600) return 4;
if(tile <= 60) return 1;
if(noise >= 0.4 && green <= 53) return 2;
if(noise >= 0.7) return 3;
return 1 + rand() % 4;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |