# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
395663 | andremfq | Art Class (IOI13_artclass) | C++17 | 74 ms | 6352 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.
/*
imagina um grafo onde o peso da aresta eh a soma das diferencas analisando a media dos pesos dessas
arestas conseguimos diferenciar bem entre os estilos 1 e 4
pra diferenciar os estilos 1 e 2, olhamos pra média da qtd de verde e branco, e pensamos num critério
e depois mudando os valores pra ver branco e verde conseguimos mais alguns pontos
*/
#include "artclass.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std ;
int H , W ;
int r[510][510] , g[510][510] , b[510][510] ;
int dx[2] = {0,1} , dy[2] = {1,0} ;
bool valid(int x, int y) { return 0 <= min(x,y) && x < H && y < W ; }
int getDiff(int x1, int y1, int x2, int y2)
{
int dr = abs(r[x1][y1]-r[x2][y2]) ;
int dg = abs(g[x1][y1]-g[x2][y2]) ;
int db = abs(b[x1][y1]-b[x2][y2]) ;
return dr+dg+db ;
}
bool isWhite(int x, int y )
{
bool ok = max({ abs(r[x][y]-g[x][y]) , abs(g[x][y]-b[x][y]) , abs(r[x][y]-b[x][y]) }) <= 15 ;
ok &= min({r[x][y] , g[x][y], b[x][y]}) >= 200 ;
return ok ;
}
bool isGreen(int x, int y) { return min(g[x][y],r[x][y]) >= b[x][y] && !isWhite(x,y) ; }
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] ;
}
int mnDiff = INT_MAX ;
int mxDiff = -INT_MAX ;
double s = 0 , s_squared = 0 ;
double cnt = 0 ;
double qtd[2] = {0,0} ;
for(int i = 0 ; i < H ; i++ )
for(int j = 0 ; j < W ; j++ )
{
if(isWhite(i,j)) qtd[0]++ ;
if( isGreen(i,j) ) qtd[1]++ ;
for(int a = 0 , ni , nj ; a < 2 ; a++ )
{
ni = i + dx[a] ;
nj = j+dy[a] ;
if(!valid(ni,nj)) continue ;
cnt++ ;
mnDiff = min(mnDiff, getDiff(i,j,ni,nj)) ;
mxDiff = max( mxDiff, getDiff(i,j,ni,nj) ) ;
s += getDiff(i,j,ni,nj) ;
}
}
s /= cnt ;
qtd[0] /= (double)(H*W) ;
qtd[1] /= (double)(H*W) ;
if( s <= 9.0 ) return 4 ;
if(s >= 50.0 ) return 3 ;
if( qtd[0] <= 0.1 ) return 2 ;
return 1 ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |