# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
585020 | benson1029 | Art Class (IOI13_artclass) | C++14 | 81 ms | 19120 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;
int h,w;
bool vis[500][500];
int v[500][500][3];
double avg[500][500][3];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
bool valid(int x, int y) {
return (x>=0&&y>=0&&x<h&&y<w);
}
bool near(int X1, int Y1, int X2, int Y2) {
return (abs(v[X1][Y1][0]-v[X2][Y2][0]) + abs(v[X1][Y1][1]-v[X2][Y2][1]) + abs(v[X1][Y1][2]-v[X2][Y2][2])) <= 20;
}
bool near2(int X1, int Y1, int X2, int Y2) {
return (abs(v[X1][Y1][0]-v[X2][Y2][0]) + abs(v[X1][Y1][1]-v[X2][Y2][1]) + abs(v[X1][Y1][2]-v[X2][Y2][2])) <= 10;
}
void dfs(int x, int y) {
vis[x][y] = true;
for(int i=0; i<4; i++) {
if(!valid(x+dx[i], y+dy[i])) continue;
if(vis[x+dx[i]][y+dy[i]]) continue;
if(near(x, y, x+dx[i], y+dy[i])) {
dfs(x+dx[i], y+dy[i]);
}
}
}
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++) {
v[i][j][0] = R[i][j];
v[i][j][1] = G[i][j];
v[i][j][2] = B[i][j];
}
int connected_component = 0;
for(int i=0; i<h; i++) for(int j=0; j<w; j++) {
if(!vis[i][j]) {
dfs(i, j);
connected_component++;
}
}
double r,g,b;
int cntg = 0;
for(int i=0; i<h; i++) for(int j=0; j<w; j++) {
r += R[i][j];
g += G[i][j];
b += B[i][j];
if(G[i][j]-60 > B[i][j] && G[i][j]+10 > R[i][j]) cntg++;
}
if(g > r && g > b) cntg += 100000;
int cntsame = 0;
for(int i=0; i<h; i++) {
for(int j=0; j<w; j++) {
if(i>=3 && near2(i, j, i-3, j)) cntsame++;
if(j>=3 && near2(i, j, i, j-3)) cntsame++;
}
}
//cout << connected_component << " " << cntg << " " << cntsame << "\n";
if(connected_component <= 1000) return 4;
if(cntsame>100000) return 1;
if(cntg > 4000) return 2;
if(connected_component <= 20000) return 2;
return 3;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |