#include "artclass.h"
#include <cstdlib>
#include <cmath>
#define D(i,j,k,l) (abs(R[i][j] - R[k][l])+abs(G[i][j] - G[k][l])+abs(B[i][j] - B[k][l]))
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
double delta = 0;
int meanR = 0, meanG = 0, meanB = 0, alldev = 0;
int buckR[16] = {}, buckG[16] = {}, buckB[16] = {};
for (int i=0; i<H; i++) {
for (int j=0; j<W; j++) {
meanR += R[i][j];
meanG += G[i][j];
meanB += B[i][j];
buckR[R[i][j]>>4]++;
buckG[G[i][j]>>4]++;
buckB[B[i][j]>>4]++;
}
}
meanR /= H*W*16;
meanG /= H*W*16;
meanB /= H*W*16;
for (int i=0; i<16; i++) {
alldev += buckR[i] * (meanR - i)*(meanR - i);
alldev += buckG[i] * (meanG - i)*(meanG - i);
alldev += buckB[i] * (meanB - i)*(meanB - i);
}
alldev /= 256;
for (int i=0; i<H; i++) {
for (int j=0; j<W-1; j++) {
double x = sqrt(D(i,j,i,j+1));
if(x > 2.2)delta += x;
}
}
for (int j=0; j<W; j++) {
for (int i=0; i<H-1; i++) {
double x = sqrt(D(i,j,i+1,j));
if(x > 2.2) delta += x;
}
}
double t = 100.0 * delta / (2 * W * H - H - W);
if(t > 660) return 3;
else if(t > 400) return 2;
else if(t < 120) return 4;
else if(t > 280) return 1;
else{ return alldev > 50000 ? 1 : 4;}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
106 ms |
3616 KB |
Output is correct |
2 |
Correct |
70 ms |
3616 KB |
Output is correct |
3 |
Correct |
120 ms |
3616 KB |
Output is correct |
4 |
Correct |
77 ms |
3580 KB |
Output is correct |
5 |
Correct |
93 ms |
3580 KB |
Output is correct |
6 |
Correct |
59 ms |
3616 KB |
Output is correct |
7 |
Correct |
78 ms |
3580 KB |
Output is correct |
8 |
Correct |
66 ms |
3616 KB |
Output is correct |
9 |
Incorrect |
86 ms |
3580 KB |
Output isn't correct |
10 |
Correct |
78 ms |
3580 KB |
Output is correct |
11 |
Correct |
79 ms |
3580 KB |
Output is correct |
12 |
Incorrect |
52 ms |
1912 KB |
Output isn't correct |
13 |
Correct |
86 ms |
3580 KB |
Output is correct |
14 |
Correct |
86 ms |
3616 KB |
Output is correct |
15 |
Correct |
33 ms |
3616 KB |
Output is correct |
16 |
Correct |
42 ms |
3616 KB |
Output is correct |
17 |
Correct |
73 ms |
3616 KB |
Output is correct |
18 |
Correct |
103 ms |
3616 KB |
Output is correct |
19 |
Correct |
120 ms |
3580 KB |
Output is correct |
20 |
Correct |
101 ms |
3452 KB |
Output is correct |
21 |
Correct |
91 ms |
3580 KB |
Output is correct |
22 |
Correct |
101 ms |
3616 KB |
Output is correct |
23 |
Correct |
78 ms |
3580 KB |
Output is correct |
24 |
Correct |
97 ms |
3564 KB |
Output is correct |
25 |
Correct |
103 ms |
3616 KB |
Output is correct |
26 |
Correct |
89 ms |
3616 KB |
Output is correct |
27 |
Incorrect |
94 ms |
3500 KB |
Output isn't correct |
28 |
Correct |
73 ms |
3580 KB |
Output is correct |
29 |
Correct |
52 ms |
3564 KB |
Output is correct |
30 |
Correct |
97 ms |
3616 KB |
Output is correct |
31 |
Correct |
61 ms |
3616 KB |
Output is correct |
32 |
Correct |
48 ms |
3616 KB |
Output is correct |
33 |
Correct |
92 ms |
3580 KB |
Output is correct |
34 |
Correct |
77 ms |
3580 KB |
Output is correct |
35 |
Correct |
127 ms |
3580 KB |
Output is correct |
36 |
Correct |
86 ms |
3616 KB |
Output is correct |
37 |
Correct |
60 ms |
3616 KB |
Output is correct |
38 |
Correct |
91 ms |
3616 KB |
Output is correct |
39 |
Correct |
118 ms |
3616 KB |
Output is correct |
40 |
Correct |
53 ms |
3616 KB |
Output is correct |
41 |
Incorrect |
74 ms |
3580 KB |
Output isn't correct |
42 |
Correct |
80 ms |
3580 KB |
Output is correct |
43 |
Correct |
71 ms |
3616 KB |
Output is correct |
44 |
Correct |
89 ms |
3564 KB |
Output is correct |
45 |
Correct |
73 ms |
3564 KB |
Output is correct |
46 |
Correct |
100 ms |
3428 KB |
Output is correct |
47 |
Correct |
51 ms |
3580 KB |
Output is correct |
48 |
Correct |
81 ms |
3616 KB |
Output is correct |
49 |
Incorrect |
91 ms |
3580 KB |
Output isn't correct |
50 |
Correct |
53 ms |
3580 KB |
Output is correct |
51 |
Correct |
72 ms |
3616 KB |
Output is correct |
52 |
Correct |
81 ms |
3616 KB |
Output is correct |
53 |
Correct |
61 ms |
3428 KB |
Output is correct |
54 |
Correct |
62 ms |
3580 KB |
Output is correct |
55 |
Correct |
47 ms |
3580 KB |
Output is correct |
56 |
Correct |
115 ms |
3580 KB |
Output is correct |
57 |
Correct |
73 ms |
3428 KB |
Output is correct |
58 |
Correct |
78 ms |
3616 KB |
Output is correct |
59 |
Correct |
70 ms |
3500 KB |
Output is correct |
60 |
Correct |
74 ms |
3616 KB |
Output is correct |
61 |
Correct |
99 ms |
3452 KB |
Output is correct |
62 |
Correct |
68 ms |
3616 KB |
Output is correct |
63 |
Correct |
75 ms |
3580 KB |
Output is correct |
64 |
Correct |
55 ms |
3580 KB |
Output is correct |
65 |
Incorrect |
69 ms |
3580 KB |
Output isn't correct |
66 |
Correct |
68 ms |
3580 KB |
Output is correct |
67 |
Correct |
56 ms |
3616 KB |
Output is correct |
68 |
Correct |
38 ms |
3616 KB |
Output is correct |
69 |
Correct |
49 ms |
3580 KB |
Output is correct |
70 |
Incorrect |
85 ms |
3500 KB |
Output isn't correct |
71 |
Correct |
69 ms |
3616 KB |
Output is correct |
72 |
Incorrect |
72 ms |
3580 KB |
Output isn't correct |
73 |
Correct |
59 ms |
3616 KB |
Output is correct |
74 |
Correct |
76 ms |
3580 KB |
Output is correct |
75 |
Correct |
87 ms |
3616 KB |
Output is correct |
76 |
Correct |
80 ms |
3616 KB |
Output is correct |
77 |
Correct |
51 ms |
3616 KB |
Output is correct |
78 |
Correct |
75 ms |
3616 KB |
Output is correct |
79 |
Correct |
84 ms |
3616 KB |
Output is correct |
80 |
Incorrect |
69 ms |
3580 KB |
Output isn't correct |
81 |
Correct |
68 ms |
3616 KB |
Output is correct |
82 |
Incorrect |
67 ms |
3580 KB |
Output isn't correct |
83 |
Incorrect |
86 ms |
3564 KB |
Output isn't correct |
84 |
Correct |
76 ms |
3580 KB |
Output is correct |
85 |
Correct |
60 ms |
3616 KB |
Output is correct |
86 |
Correct |
67 ms |
3616 KB |
Output is correct |
87 |
Correct |
83 ms |
3616 KB |
Output is correct |
88 |
Incorrect |
99 ms |
3564 KB |
Output isn't correct |
89 |
Correct |
32 ms |
3616 KB |
Output is correct |
90 |
Correct |
60 ms |
3616 KB |
Output is correct |
91 |
Correct |
74 ms |
3580 KB |
Output is correct |
92 |
Correct |
90 ms |
3580 KB |
Output is correct |
93 |
Correct |
78 ms |
3580 KB |
Output is correct |
94 |
Correct |
75 ms |
3616 KB |
Output is correct |
95 |
Correct |
55 ms |
3580 KB |
Output is correct |
96 |
Correct |
101 ms |
3616 KB |
Output is correct |
97 |
Correct |
94 ms |
3500 KB |
Output is correct |
98 |
Correct |
106 ms |
3564 KB |
Output is correct |
99 |
Correct |
82 ms |
3616 KB |
Output is correct |
100 |
Correct |
102 ms |
3428 KB |
Output is correct |
101 |
Correct |
65 ms |
3616 KB |
Output is correct |
102 |
Correct |
78 ms |
3580 KB |
Output is correct |