# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29777 | Nikefor | Art Class (IOI13_artclass) | C++98 | 188 ms | 37804 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<cmath>
int ctr = 0;
bool visit[501][501];
int h, w;
int r[500][500], g[500][500], b[500][500];
bool match(int i1, int j1, int i2, int j2) {
if(std::abs(r[i1][j1]-r[i2][j2]) > 50 ) return false;
if(std::abs(g[i1][j1]-g[i2][j2]) > 50 ) return false;
if(std::abs(b[i1][j1]-b[i2][j2]) > 50 ) return false;
return true;
}
void DFS(int i, int j) {
visit[i][j] = true;
if(i!=0 and match(i, j, i-1, j) and !visit[i-1][j]) DFS(i-1,j);
if(i!=h-1 and match(i, j, i+1, j) and !visit[i+1][j]) DFS(i+1, j);
if(j!=0 and match(i, j, i, j-1) and !visit[i][j-1]) DFS(i,j-1);
if(j!=w-1 and match(i, j, i, j+1) and !visit[i][j+1]) DFS(i, j+1);
}
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<500; j++) {
r[i][j] = R[i][j];
g[i][j] = G[i][j];
b[i][j] = B[i][j];
}
for(int i=0; i<500; i++)
for(int j=0; j<500; j++) {
if(!visit[i][j]) {
ctr++;
DFS(i,j);
}
}
// if(ctr<7) return 4;
//if(ctr<800) return 2;
if(ctr<3000) return 1;
return 3;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |