# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
97529 | tincamatei | Art Class (IOI13_artclass) | C++14 | 128 ms | 24944 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>
const int SAMECOLOR = 100;
int H, W, R[500][500], G[500][500], B[500][500];
bool viz[500][500];
int comp;
int neoplastic() {
return -abs(comp - 100);
}
int impressionist() {
return -abs(comp - 500);
}
int expressionist() {
return -abs(comp - 7000);
}
int colourfield() {
return -abs(comp - 5);
}
int dl[] = {0, 1, 0, -1};
int dc[] = {1, 0,-1, 0};
void dfs(int l, int c) {
viz[l][c] = true;
for(int i = 0; i < 4; ++i) {
int ln = l + dl[i];
int cn = c + dc[i];
if(0 <= ln && ln < H && 0 <= cn && cn < W && !viz[ln][cn] &&
abs(R[l][c] - R[ln][cn]) +
abs(G[l][c] - G[ln][cn]) +
abs(B[l][c] - B[ln][cn]) <= SAMECOLOR) {
dfs(ln, cn);
}
}
}
void getData() {
for(int i = 0; i < H; ++i)
for(int j = 0; j < W; ++j)
if(!viz[i][j]) {
dfs(i, j);
comp++;
}
}
int style(int _H, int _W, int _R[500][500], int _G[500][500], int _B[500][500]) {
H = _H;
W = _W;
for(int i = 0; i < H; ++i)
for(int j = 0; j < W; ++j) {
R[i][j] = _R[i][j];
G[i][j] = _G[i][j];
B[i][j] = _B[i][j];
}
getData();
int score[4] = {neoplastic(), impressionist(), expressionist(), colourfield()};
printf("NR COMP %d\n", comp);
int best = -1000000000, style = -1;
for(int i = 0; i < 4; ++i)
if(score[i] > best) {
best = score[i];
style = i + 1;
}
return style;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |