# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962318 | serkanrashid | Art Class (IOI13_artclass) | C++14 | 0 ms | 0 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;
struct Point
{
int x,y;
Point(){};
Point(int xi, int yi)
{
x = xi;
y = yi;
}
bool is_valid()
{
return x>=0&&x<h&&y>=0&&y<w;
}
};
Point dir[4] = {{1,0},{-1,0},{0,1},{0,-1}};
int r[500][500],g[500][500],b[500][500];
int c[500][500],used[500][500];
vector<int>comp;
map<int,int>mymap;
void dfs(Point beg)
{
used[beg.x][beg.y] = 1;
for(int i = 0; i < 4; i++)
{
Point nb;
nb.x = w.x + dir[i].x;
nb.y = w.y + dir[i].y;
if(nb.is_valid() && !used[nb.x][nb.y]) dfs(nb);
}
}
int col_br;
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]/10;
g[i][j] = G[i][j]/10;
b[i][j] = B[i][j]/10;
c[i][j] = r[i][j]*10000 + g[i][j]*100 + b[i][j];
}
}
for(int i = 0; i < H; i++)
{
for(int j = 0; j < W; j++)
{
if(!used[i][j])
{
dfs({i,j});
comp.push_back(c[i][j]);
mymap[c[i][j]]++;
if(mymap[c[i][j]]==1) col_br++;
}
}
}
if(col_br<=4&&comp.size()<=5) return 4;
if(col_br<=7&&comp.size()<=30) return 1;
if(col_br>=50&&comp.size()>=200) return 2;
return 3;
}