# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
395657 | andremfq | Art Class (IOI13_artclass) | C++17 | 74 ms | 6284 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
*/
#include "artclass.h"
#include <bits/stdc++.h>
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 ;
}
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 ;
double cnt = 0 ;
for(int i = 0 ; i < H ; i++ )
for(int j = 0 ; j < W ; j++ )
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 ;
if( s <= 9.0 ) return 4 ;
if(s >= 50.0 ) return 3 ;
return 1 ;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |