#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]}) >= 180 ;
return ok ;
}
bool isGreen(int x, int y) { return max(b[x][y],r[x][y]) + 35 <= g[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(s >= 23.0 ) return 2 ;
if( qtd[0] <= 0.06 ) return 2 ;
return 1 ;
}
Compilation message
artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:44:17: warning: unused variable 's_squared' [-Wunused-variable]
44 | double s = 0 , s_squared = 0 ;
| ^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
48 ms |
6196 KB |
Output is correct |
2 |
Correct |
58 ms |
6316 KB |
Output is correct |
3 |
Correct |
48 ms |
6140 KB |
Output is correct |
4 |
Correct |
52 ms |
4800 KB |
Output is correct |
5 |
Correct |
56 ms |
6192 KB |
Output is correct |
6 |
Correct |
85 ms |
6172 KB |
Output is correct |
7 |
Correct |
45 ms |
4040 KB |
Output is correct |
8 |
Correct |
70 ms |
6084 KB |
Output is correct |
9 |
Correct |
43 ms |
6152 KB |
Output is correct |
10 |
Correct |
46 ms |
3964 KB |
Output is correct |
11 |
Correct |
58 ms |
5136 KB |
Output is correct |
12 |
Correct |
60 ms |
6120 KB |
Output is correct |
13 |
Correct |
78 ms |
6220 KB |
Output is correct |
14 |
Correct |
67 ms |
6220 KB |
Output is correct |
15 |
Correct |
15 ms |
1484 KB |
Output is correct |
16 |
Correct |
86 ms |
6180 KB |
Output is correct |
17 |
Incorrect |
72 ms |
6216 KB |
Output isn't correct |
18 |
Correct |
47 ms |
4128 KB |
Output is correct |
19 |
Correct |
40 ms |
6212 KB |
Output is correct |
20 |
Correct |
46 ms |
6212 KB |
Output is correct |
21 |
Incorrect |
57 ms |
5276 KB |
Output isn't correct |
22 |
Correct |
45 ms |
6124 KB |
Output is correct |
23 |
Correct |
46 ms |
6108 KB |
Output is correct |
24 |
Correct |
52 ms |
6176 KB |
Output is correct |
25 |
Correct |
70 ms |
6144 KB |
Output is correct |
26 |
Correct |
63 ms |
6212 KB |
Output is correct |
27 |
Correct |
59 ms |
6340 KB |
Output is correct |
28 |
Incorrect |
57 ms |
6132 KB |
Output isn't correct |
29 |
Correct |
29 ms |
2680 KB |
Output is correct |
30 |
Incorrect |
58 ms |
6216 KB |
Output isn't correct |
31 |
Correct |
76 ms |
5248 KB |
Output is correct |
32 |
Correct |
57 ms |
5180 KB |
Output is correct |
33 |
Correct |
38 ms |
3524 KB |
Output is correct |
34 |
Correct |
71 ms |
4940 KB |
Output is correct |
35 |
Correct |
61 ms |
6220 KB |
Output is correct |
36 |
Correct |
42 ms |
6220 KB |
Output is correct |
37 |
Correct |
60 ms |
6116 KB |
Output is correct |
38 |
Correct |
57 ms |
5088 KB |
Output is correct |
39 |
Correct |
60 ms |
6152 KB |
Output is correct |
40 |
Correct |
36 ms |
3268 KB |
Output is correct |
41 |
Correct |
63 ms |
5596 KB |
Output is correct |
42 |
Correct |
60 ms |
5396 KB |
Output is correct |
43 |
Correct |
56 ms |
4984 KB |
Output is correct |
44 |
Correct |
59 ms |
5304 KB |
Output is correct |
45 |
Correct |
70 ms |
6116 KB |
Output is correct |
46 |
Correct |
36 ms |
3268 KB |
Output is correct |
47 |
Correct |
70 ms |
6192 KB |
Output is correct |
48 |
Correct |
69 ms |
6012 KB |
Output is correct |
49 |
Correct |
56 ms |
6192 KB |
Output is correct |
50 |
Correct |
56 ms |
6176 KB |
Output is correct |
51 |
Correct |
46 ms |
6172 KB |
Output is correct |
52 |
Incorrect |
71 ms |
6112 KB |
Output isn't correct |
53 |
Correct |
61 ms |
6172 KB |
Output is correct |
54 |
Correct |
58 ms |
6104 KB |
Output is correct |
55 |
Correct |
53 ms |
4816 KB |
Output is correct |
56 |
Correct |
56 ms |
6108 KB |
Output is correct |
57 |
Correct |
71 ms |
6212 KB |
Output is correct |
58 |
Correct |
60 ms |
6200 KB |
Output is correct |
59 |
Incorrect |
72 ms |
4676 KB |
Output isn't correct |
60 |
Correct |
54 ms |
4720 KB |
Output is correct |
61 |
Correct |
87 ms |
6244 KB |
Output is correct |
62 |
Correct |
61 ms |
4892 KB |
Output is correct |
63 |
Correct |
57 ms |
6196 KB |
Output is correct |
64 |
Incorrect |
51 ms |
6140 KB |
Output isn't correct |
65 |
Correct |
78 ms |
6168 KB |
Output is correct |
66 |
Correct |
53 ms |
4660 KB |
Output is correct |
67 |
Incorrect |
65 ms |
4640 KB |
Output isn't correct |
68 |
Correct |
31 ms |
2784 KB |
Output is correct |
69 |
Correct |
50 ms |
6212 KB |
Output is correct |
70 |
Correct |
57 ms |
4992 KB |
Output is correct |
71 |
Correct |
37 ms |
3204 KB |
Output is correct |
72 |
Correct |
30 ms |
2624 KB |
Output is correct |
73 |
Correct |
59 ms |
6100 KB |
Output is correct |
74 |
Correct |
51 ms |
6104 KB |
Output is correct |
75 |
Incorrect |
79 ms |
6132 KB |
Output isn't correct |
76 |
Correct |
59 ms |
5140 KB |
Output is correct |
77 |
Correct |
55 ms |
6168 KB |
Output is correct |
78 |
Correct |
72 ms |
6224 KB |
Output is correct |
79 |
Correct |
71 ms |
6212 KB |
Output is correct |
80 |
Correct |
48 ms |
6212 KB |
Output is correct |
81 |
Incorrect |
52 ms |
4824 KB |
Output isn't correct |
82 |
Correct |
44 ms |
3896 KB |
Output is correct |
83 |
Correct |
58 ms |
5192 KB |
Output is correct |
84 |
Correct |
37 ms |
3324 KB |
Output is correct |
85 |
Correct |
68 ms |
6124 KB |
Output is correct |
86 |
Correct |
48 ms |
6124 KB |
Output is correct |
87 |
Correct |
53 ms |
4828 KB |
Output is correct |
88 |
Incorrect |
62 ms |
5412 KB |
Output isn't correct |
89 |
Correct |
86 ms |
5780 KB |
Output is correct |
90 |
Correct |
59 ms |
5192 KB |
Output is correct |
91 |
Correct |
44 ms |
6136 KB |
Output is correct |
92 |
Correct |
59 ms |
6176 KB |
Output is correct |
93 |
Correct |
73 ms |
5016 KB |
Output is correct |
94 |
Correct |
18 ms |
6184 KB |
Output is correct |
95 |
Correct |
49 ms |
4212 KB |
Output is correct |
96 |
Correct |
64 ms |
6212 KB |
Output is correct |
97 |
Correct |
55 ms |
4892 KB |
Output is correct |
98 |
Correct |
53 ms |
5000 KB |
Output is correct |
99 |
Correct |
57 ms |
6224 KB |
Output is correct |
100 |
Correct |
52 ms |
4632 KB |
Output is correct |
101 |
Correct |
60 ms |
6124 KB |
Output is correct |
102 |
Correct |
57 ms |
6180 KB |
Output is correct |