# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1035756 | why_5_mins | Art Class (IOI13_artclass) | C++14 | 61 ms | 39940 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 HH,WW;
int const_dif_lejer = 50;
int const_dif_hard = 20;
int RR[505][505],GG[505][505],BB[505][505];
bool similar(int r1, int g1, int b1, int r2, int g2, int b2, int const_dif)
{
if (abs(r1 - r2) > const_dif or abs(g1 - g2) > const_dif or abs(b1 - b2) > const_dif)
return false;
return true;
}
bool sim(int l1, int c1, int l2, int c2)
{
return similar(RR[l1][c1], GG[l1][c1], BB[l1][c1], RR[l2][c2], GG[l2][c2], BB[l2][c2], const_dif_lejer);
}
int dl[] = {-1,0,1,0};
int dc[] = {0,1,0,-1};
bool viz[505][505];
void dfs(int lin, int col)
{
viz[lin][col] = true;
for (int i = 0; i < 4; i++)
{
int nl = lin + dl[i],nc = col + dc[i];
if (nl >= 0 and nl < HH and nc >= 0 and nc < WW and sim(lin,col,nl,nc) and !viz[nl][nc])
dfs(nl,nc);
}
}
bool stil_4()
{
for (int i = 0; i < HH; i++)
for (int j = 0; j < WW; j++)
viz[i][j] = false;
int cc = 0;
for (int i = 0; i < HH; i++)
for (int j = 0; j < WW; j++)
if (!viz[i][j])
cc++,dfs(i,j);
if (cc <= 10)
return true;
return false;
}
bool stil_1()
{
int cntW = 0;
for (int i = 0; i < HH; i++)
for (int j = 0; j < WW; j++)
if (similar(RR[i][j],GG[i][j],BB[i][j],255,255,255,const_dif_lejer))
cntW++;
if (cntW >= HH * WW / 5)
return true;
return false;
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500])
{
HH = H;
WW = W;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++)
RR[i][j] = R[i][j],GG[i][j] = G[i][j],BB[i][j] = B[i][j];
if (stil_1())
return 1;
if (stil_4())
return 4;
assert(false);
}
/// stil 1 -> exista o culoare, a.i daca ii iau componentele conexe din ea, le marchez ca blocate, componentele ramase o sa fie "uniforme"
/// stil 2 -> pana mea, mult verde s-ar putea crede
/// stil 3 -> kys
/// stil 4 -> putine componente conexe
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |