Submission #658323

# Submission time Handle Problem Language Result Execution time Memory
658323 2022-11-12T19:38:54 Z cristi_a Art Class (IOI13_artclass) C++17
93 / 100
60 ms 3304 KB
#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.35) return 4;
    if(snp_percent >= 27.00) return 3;
    if(green_diff_sum >= 20 and snp_percent <= 15.00) return 2;
    return 1;
}
# Verdict Execution time Memory Grader output
1 Correct 44 ms 2524 KB Output is correct
2 Correct 30 ms 3232 KB Output is correct
3 Correct 34 ms 2100 KB Output is correct
4 Correct 54 ms 3148 KB Output is correct
5 Correct 46 ms 2784 KB Output is correct
6 Correct 42 ms 3304 KB Output is correct
7 Correct 53 ms 3116 KB Output is correct
8 Correct 52 ms 3104 KB Output is correct
9 Correct 30 ms 1712 KB Output is correct
10 Correct 51 ms 2108 KB Output is correct
11 Correct 45 ms 3136 KB Output is correct
12 Correct 34 ms 3164 KB Output is correct
13 Correct 46 ms 3108 KB Output is correct
14 Incorrect 43 ms 3212 KB Output isn't correct
15 Correct 40 ms 2468 KB Output is correct
16 Correct 53 ms 3136 KB Output is correct
17 Correct 45 ms 2612 KB Output is correct
18 Correct 37 ms 3144 KB Output is correct
19 Correct 47 ms 2932 KB Output is correct
20 Correct 37 ms 2160 KB Output is correct
21 Correct 43 ms 3204 KB Output is correct
22 Correct 41 ms 3160 KB Output is correct
23 Correct 33 ms 3148 KB Output is correct
24 Correct 44 ms 2648 KB Output is correct
25 Correct 54 ms 3212 KB Output is correct
26 Correct 44 ms 3104 KB Output is correct
27 Correct 37 ms 3204 KB Output is correct
28 Correct 45 ms 3172 KB Output is correct
29 Correct 43 ms 2580 KB Output is correct
30 Correct 48 ms 3192 KB Output is correct
31 Incorrect 40 ms 2436 KB Output isn't correct
32 Correct 34 ms 3192 KB Output is correct
33 Correct 35 ms 3228 KB Output is correct
34 Correct 40 ms 2432 KB Output is correct
35 Correct 44 ms 3168 KB Output is correct
36 Correct 52 ms 3148 KB Output is correct
37 Correct 33 ms 3208 KB Output is correct
38 Correct 46 ms 3108 KB Output is correct
39 Correct 45 ms 3284 KB Output is correct
40 Incorrect 44 ms 2736 KB Output isn't correct
41 Correct 54 ms 3104 KB Output is correct
42 Correct 46 ms 2668 KB Output is correct
43 Correct 37 ms 3140 KB Output is correct
44 Incorrect 47 ms 2788 KB Output isn't correct
45 Correct 42 ms 3148 KB Output is correct
46 Correct 24 ms 1540 KB Output is correct
47 Incorrect 54 ms 3128 KB Output isn't correct
48 Correct 51 ms 3128 KB Output is correct
49 Incorrect 41 ms 2624 KB Output isn't correct
50 Correct 27 ms 1752 KB Output is correct
51 Correct 44 ms 3212 KB Output is correct
52 Correct 44 ms 3128 KB Output is correct
53 Correct 54 ms 3288 KB Output is correct
54 Correct 37 ms 3132 KB Output is correct
55 Correct 43 ms 2612 KB Output is correct
56 Correct 41 ms 2380 KB Output is correct
57 Correct 44 ms 3156 KB Output is correct
58 Incorrect 41 ms 2464 KB Output isn't correct
59 Incorrect 40 ms 2404 KB Output isn't correct
60 Incorrect 48 ms 2672 KB Output isn't correct
61 Correct 47 ms 3148 KB Output is correct
62 Correct 29 ms 1876 KB Output is correct
63 Incorrect 34 ms 2100 KB Output isn't correct
64 Correct 44 ms 2688 KB Output is correct
65 Correct 46 ms 3188 KB Output is correct
66 Correct 45 ms 2772 KB Output is correct
67 Correct 39 ms 2348 KB Output is correct
68 Correct 44 ms 2724 KB Output is correct
69 Correct 53 ms 3176 KB Output is correct
70 Correct 22 ms 1412 KB Output is correct
71 Correct 23 ms 1420 KB Output is correct
72 Correct 44 ms 3108 KB Output is correct
73 Correct 29 ms 1748 KB Output is correct
74 Correct 43 ms 3164 KB Output is correct
75 Correct 41 ms 2536 KB Output is correct
76 Correct 28 ms 1796 KB Output is correct
77 Correct 51 ms 3236 KB Output is correct
78 Correct 39 ms 3260 KB Output is correct
79 Correct 40 ms 2416 KB Output is correct
80 Correct 50 ms 3208 KB Output is correct
81 Correct 43 ms 3232 KB Output is correct
82 Correct 52 ms 3148 KB Output is correct
83 Incorrect 41 ms 2576 KB Output isn't correct
84 Correct 43 ms 2508 KB Output is correct
85 Correct 48 ms 3020 KB Output is correct
86 Incorrect 18 ms 3188 KB Output isn't correct
87 Correct 41 ms 3196 KB Output is correct
88 Correct 60 ms 2688 KB Output is correct
89 Correct 31 ms 3164 KB Output is correct
90 Correct 42 ms 3148 KB Output is correct
91 Incorrect 47 ms 3160 KB Output isn't correct
92 Correct 52 ms 3148 KB Output is correct
93 Correct 35 ms 3148 KB Output is correct
94 Correct 45 ms 3104 KB Output is correct
95 Correct 34 ms 2084 KB Output is correct
96 Correct 46 ms 3196 KB Output is correct
97 Correct 55 ms 3208 KB Output is correct
98 Correct 36 ms 3216 KB Output is correct
99 Correct 27 ms 3156 KB Output is correct
100 Correct 11 ms 884 KB Output is correct
101 Correct 40 ms 2492 KB Output is correct
102 Correct 43 ms 3112 KB Output is correct