#include <bits/stdc++.h>
#include "artclass.h"
using namespace std;
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
static const int dx[] = {0, 0, -1, 1};
static const int dy[] = {1, -1, 0, 0};
static const int area = H * W;
auto in = [&](int a, int b) {
if(a < 0 or a >= H or b < 0 or b >= W) return false;
return true;
};
int red_sum = 0;
int green_sum = 0;
int blue_sum = 0;
int salt_and_pepper = 0;
for(int i=0; i<H; i++)
for(int j=0; j<W; j++) {
red_sum += R[i][j];
green_sum += G[i][j];
blue_sum += B[i][j];
for(int k=0; k<4; k++) {
int ni = i + dx[k];
int nj = j + dy[k];
if(!in(ni, nj)) continue;
int difs = abs(R[i][j] - R[ni][nj]) +
abs(G[i][j] - G[ni][nj]) +
abs(B[i][j] - B[ni][nj]);
if(difs >= 140) salt_and_pepper++;
}
}
double snp_percent = 1.00 * salt_and_pepper / (2.00 * area) * 100.00;
double red_avg = 1.00 * red_sum / (1.00 * area);
double blue_avg = 1.00 * blue_sum / (1.00 * area);
double green_avg = 1.00 * green_sum / (1.00 * area);
double green_diff_sum = (green_avg - blue_avg) + (green_avg - red_avg);
if(snp_percent <= 0.70) return 4;
if(snp_percent >= 25.00) return 3;
if(green_diff_sum >= 19.00 and snp_percent <= 15.00) return 2;
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1496 KB |
Output is correct |
2 |
Correct |
41 ms |
2432 KB |
Output is correct |
3 |
Correct |
53 ms |
3176 KB |
Output is correct |
4 |
Correct |
50 ms |
2540 KB |
Output is correct |
5 |
Correct |
40 ms |
2380 KB |
Output is correct |
6 |
Correct |
50 ms |
3208 KB |
Output is correct |
7 |
Correct |
45 ms |
2736 KB |
Output is correct |
8 |
Correct |
42 ms |
2540 KB |
Output is correct |
9 |
Correct |
59 ms |
3144 KB |
Output is correct |
10 |
Correct |
26 ms |
1504 KB |
Output is correct |
11 |
Correct |
54 ms |
3280 KB |
Output is correct |
12 |
Correct |
45 ms |
3128 KB |
Output is correct |
13 |
Correct |
47 ms |
3156 KB |
Output is correct |
14 |
Correct |
34 ms |
2156 KB |
Output is correct |
15 |
Correct |
45 ms |
3224 KB |
Output is correct |
16 |
Correct |
38 ms |
3156 KB |
Output is correct |
17 |
Correct |
59 ms |
3196 KB |
Output is correct |
18 |
Correct |
47 ms |
3148 KB |
Output is correct |
19 |
Correct |
46 ms |
3220 KB |
Output is correct |
20 |
Correct |
58 ms |
3128 KB |
Output is correct |
21 |
Correct |
53 ms |
3244 KB |
Output is correct |
22 |
Correct |
41 ms |
3104 KB |
Output is correct |
23 |
Incorrect |
46 ms |
3148 KB |
Output isn't correct |
24 |
Correct |
42 ms |
3148 KB |
Output is correct |
25 |
Correct |
34 ms |
2144 KB |
Output is correct |
26 |
Correct |
52 ms |
3148 KB |
Output is correct |
27 |
Correct |
42 ms |
2508 KB |
Output is correct |
28 |
Correct |
35 ms |
3132 KB |
Output is correct |
29 |
Correct |
38 ms |
3112 KB |
Output is correct |
30 |
Correct |
49 ms |
3424 KB |
Output is correct |
31 |
Correct |
28 ms |
1688 KB |
Output is correct |
32 |
Correct |
28 ms |
1752 KB |
Output is correct |
33 |
Correct |
45 ms |
2764 KB |
Output is correct |
34 |
Incorrect |
46 ms |
2808 KB |
Output isn't correct |
35 |
Incorrect |
13 ms |
3232 KB |
Output isn't correct |
36 |
Incorrect |
41 ms |
2516 KB |
Output isn't correct |
37 |
Correct |
43 ms |
3108 KB |
Output is correct |
38 |
Correct |
43 ms |
3192 KB |
Output is correct |
39 |
Correct |
34 ms |
3144 KB |
Output is correct |
40 |
Correct |
63 ms |
3148 KB |
Output is correct |
41 |
Correct |
50 ms |
3148 KB |
Output is correct |
42 |
Correct |
38 ms |
2204 KB |
Output is correct |
43 |
Correct |
46 ms |
3200 KB |
Output is correct |
44 |
Correct |
28 ms |
1788 KB |
Output is correct |
45 |
Correct |
33 ms |
3212 KB |
Output is correct |
46 |
Correct |
53 ms |
3164 KB |
Output is correct |
47 |
Correct |
48 ms |
3188 KB |
Output is correct |
48 |
Correct |
45 ms |
2812 KB |
Output is correct |
49 |
Correct |
52 ms |
2528 KB |
Output is correct |
50 |
Correct |
33 ms |
2012 KB |
Output is correct |
51 |
Incorrect |
44 ms |
2608 KB |
Output isn't correct |
52 |
Correct |
43 ms |
2684 KB |
Output is correct |
53 |
Correct |
59 ms |
3184 KB |
Output is correct |
54 |
Correct |
38 ms |
3132 KB |
Output is correct |
55 |
Correct |
41 ms |
3164 KB |
Output is correct |
56 |
Incorrect |
56 ms |
3184 KB |
Output isn't correct |
57 |
Correct |
43 ms |
2556 KB |
Output is correct |
58 |
Correct |
47 ms |
2764 KB |
Output is correct |
59 |
Correct |
41 ms |
3180 KB |
Output is correct |
60 |
Correct |
38 ms |
3148 KB |
Output is correct |
61 |
Correct |
45 ms |
3112 KB |
Output is correct |
62 |
Correct |
44 ms |
3100 KB |
Output is correct |
63 |
Incorrect |
43 ms |
2668 KB |
Output isn't correct |
64 |
Correct |
42 ms |
3148 KB |
Output is correct |
65 |
Correct |
48 ms |
3212 KB |
Output is correct |
66 |
Correct |
59 ms |
2452 KB |
Output is correct |
67 |
Correct |
47 ms |
3180 KB |
Output is correct |
68 |
Correct |
47 ms |
3136 KB |
Output is correct |
69 |
Correct |
30 ms |
1868 KB |
Output is correct |
70 |
Correct |
51 ms |
3172 KB |
Output is correct |
71 |
Correct |
32 ms |
3148 KB |
Output is correct |
72 |
Incorrect |
48 ms |
2360 KB |
Output isn't correct |
73 |
Correct |
45 ms |
3128 KB |
Output is correct |
74 |
Correct |
41 ms |
2400 KB |
Output is correct |
75 |
Correct |
43 ms |
2608 KB |
Output is correct |
76 |
Correct |
34 ms |
1996 KB |
Output is correct |
77 |
Correct |
43 ms |
3148 KB |
Output is correct |
78 |
Correct |
53 ms |
3128 KB |
Output is correct |
79 |
Correct |
41 ms |
2612 KB |
Output is correct |
80 |
Correct |
23 ms |
1480 KB |
Output is correct |
81 |
Correct |
52 ms |
3200 KB |
Output is correct |
82 |
Correct |
53 ms |
3068 KB |
Output is correct |
83 |
Correct |
44 ms |
2640 KB |
Output is correct |
84 |
Correct |
43 ms |
3124 KB |
Output is correct |
85 |
Correct |
30 ms |
3124 KB |
Output is correct |
86 |
Correct |
51 ms |
3132 KB |
Output is correct |
87 |
Correct |
28 ms |
1748 KB |
Output is correct |
88 |
Correct |
26 ms |
3232 KB |
Output is correct |
89 |
Correct |
43 ms |
3208 KB |
Output is correct |
90 |
Correct |
11 ms |
852 KB |
Output is correct |
91 |
Correct |
53 ms |
3156 KB |
Output is correct |
92 |
Correct |
48 ms |
3164 KB |
Output is correct |
93 |
Correct |
44 ms |
2712 KB |
Output is correct |
94 |
Correct |
46 ms |
2736 KB |
Output is correct |
95 |
Correct |
44 ms |
3188 KB |
Output is correct |
96 |
Correct |
40 ms |
2512 KB |
Output is correct |
97 |
Correct |
52 ms |
3192 KB |
Output is correct |
98 |
Correct |
33 ms |
3148 KB |
Output is correct |
99 |
Correct |
50 ms |
2784 KB |
Output is correct |
100 |
Correct |
44 ms |
2636 KB |
Output is correct |
101 |
Incorrect |
41 ms |
2416 KB |
Output isn't correct |
102 |
Correct |
45 ms |
3200 KB |
Output is correct |