Submission #554093

# Submission time Handle Problem Language Result Execution time Memory
554093 2022-04-27T16:21:26 Z elazarkoren Art Class (IOI13_artclass) C++17
0 / 100
70 ms 6868 KB
#include "artclass.h"
#include <bits/stdc++.h>
#define x first
#define y second
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;

const int infinity = 1e9;

struct Style{
    int red, green, blue, gray;
    Style() {}
    Style(int r, int g, int b, int gr): red(r), green(g), blue(b), gray(gr) {}
    int Close(int r, int g, int b, int gr) {
        return abs(r - red) + abs(g - green) + abs(b - blue) + abs(gr - gray);
    }
};

Style s[] = {Style(), Style(146, 166, 146, 167), Style(67, 97, 63, 87), Style(106, 128, 106, 124), Style(54, 89, 54, 100)};

int cnt[5];

int ClosestR(int x) {
    int ans = infinity;
    for (int i = 1; i <= 4; i++) {
        chkmin(ans, abs(x - s[i].red));
    }
    for (int i = 1; i <= 4; i++) {
        if (abs(x - s[i].red) == ans) {
            cnt[i]++;
        }
    }
}

int ClosestG(int x) {
    int ans = infinity;
    for (int i = 1; i <= 4; i++) {
        chkmin(ans, abs(x - s[i].green));
    }
    for (int i = 1; i <= 4; i++) {
        if (abs(x - s[i].green) == ans) {
            cnt[i]++;
        }
    }
}

int ClosestB(int x) {
    int ans = infinity;
    for (int i = 1; i <= 4; i++) {
        chkmin(ans, abs(x - s[i].blue));
    }
    for (int i = 1; i <= 4; i++) {
        if (abs(x - s[i].blue) == ans) {
            cnt[i]++;
        }
    }
}

int ClosestGr(int x) {
    int ans = infinity;
    for (int i = 1; i <= 4; i++) {
        chkmin(ans, abs(x - s[i].gray));
    }
    for (int i = 1; i <= 4; i++) {
        if (abs(x - s[i].gray) == ans) {
            cnt[i]++;
        }
    }
}


int style(int h, int w, int r[500][500], int g[500][500], int b[500][500]) {
    ll sum_r = 0, sum_g = 0, sum_b = 0, gray_scale = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            sum_r += r[i][j], sum_g += g[i][j], sum_b += b[i][j];
            gray_scale += (r[i][j] + g[i][j] + b[i][j]) / 3;
        }
    }
    sum_r /= (h * w);
    sum_g /= (h * w);
    sum_b /= (h * w);
    gray_scale /= (h * w);
    cnt[1] = cnt[2] = cnt[3] = cnt[4] = 0;
    ClosestR(sum_r), ClosestG(sum_g), ClosestB(sum_b), ClosestGr(gray_scale);
    int max_cnt = 0;
    for (int i = 1; i <= 4; i++) {
        chkmax(max_cnt, cnt[i]);
    }
    pii ans = {infinity, 0};
    for (int i = 1; i <= 4; i++) {
        if (cnt[i] == max_cnt) {
            pii q = {s[i].Close(sum_r, sum_g, sum_b, gray_scale), i};
            chkmin(ans, q);
        }
    }
    return ans.y;
}

Compilation message

artclass.cpp: In function 'int ClosestR(int)':
artclass.cpp:39:1: warning: no return statement in function returning non-void [-Wreturn-type]
   39 | }
      | ^
artclass.cpp: In function 'int ClosestG(int)':
artclass.cpp:51:1: warning: no return statement in function returning non-void [-Wreturn-type]
   51 | }
      | ^
artclass.cpp: In function 'int ClosestB(int)':
artclass.cpp:63:1: warning: no return statement in function returning non-void [-Wreturn-type]
   63 | }
      | ^
artclass.cpp: In function 'int ClosestGr(int)':
artclass.cpp:75:1: warning: no return statement in function returning non-void [-Wreturn-type]
   75 | }
      | ^
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 5496 KB Execution killed with signal 11
2 Runtime error 32 ms 6792 KB Execution killed with signal 11
3 Runtime error 38 ms 5460 KB Execution killed with signal 11
4 Runtime error 42 ms 5472 KB Execution killed with signal 11
5 Runtime error 42 ms 5612 KB Execution killed with signal 11
6 Runtime error 39 ms 5452 KB Execution killed with signal 11
7 Runtime error 53 ms 6760 KB Execution killed with signal 11
8 Runtime error 43 ms 5644 KB Execution killed with signal 11
9 Runtime error 27 ms 3968 KB Execution killed with signal 11
10 Runtime error 42 ms 5360 KB Execution killed with signal 11
11 Runtime error 70 ms 6788 KB Execution killed with signal 11
12 Runtime error 40 ms 5508 KB Execution killed with signal 11
13 Runtime error 34 ms 4680 KB Execution killed with signal 11
14 Runtime error 47 ms 5952 KB Execution killed with signal 11
15 Runtime error 46 ms 5816 KB Execution killed with signal 11
16 Runtime error 48 ms 6860 KB Execution killed with signal 11
17 Runtime error 43 ms 6832 KB Execution killed with signal 11
18 Runtime error 50 ms 6000 KB Execution killed with signal 11
19 Runtime error 48 ms 6780 KB Execution killed with signal 11
20 Runtime error 39 ms 5324 KB Execution killed with signal 11
21 Runtime error 41 ms 6844 KB Execution killed with signal 11
22 Runtime error 38 ms 6796 KB Execution killed with signal 11
23 Runtime error 32 ms 6760 KB Execution killed with signal 11
24 Runtime error 41 ms 5196 KB Execution killed with signal 11
25 Runtime error 50 ms 6836 KB Execution killed with signal 11
26 Runtime error 55 ms 6860 KB Execution killed with signal 11
27 Runtime error 45 ms 5964 KB Execution killed with signal 11
28 Runtime error 36 ms 6840 KB Execution killed with signal 11
29 Runtime error 36 ms 6832 KB Execution killed with signal 11
30 Runtime error 52 ms 6832 KB Execution killed with signal 11
31 Runtime error 51 ms 6076 KB Execution killed with signal 11
32 Runtime error 15 ms 6868 KB Execution killed with signal 11
33 Runtime error 44 ms 6856 KB Execution killed with signal 11
34 Runtime error 46 ms 6748 KB Execution killed with signal 11
35 Runtime error 37 ms 6812 KB Execution killed with signal 11
36 Runtime error 28 ms 3872 KB Execution killed with signal 11
37 Runtime error 45 ms 6860 KB Execution killed with signal 11
38 Runtime error 55 ms 6724 KB Execution killed with signal 11
39 Runtime error 45 ms 5820 KB Execution killed with signal 11
40 Runtime error 44 ms 5820 KB Execution killed with signal 11
41 Runtime error 47 ms 6744 KB Execution killed with signal 11
42 Runtime error 47 ms 5808 KB Execution killed with signal 11
43 Runtime error 34 ms 6780 KB Execution killed with signal 11
44 Runtime error 43 ms 6848 KB Execution killed with signal 11
45 Runtime error 48 ms 6832 KB Execution killed with signal 11
46 Runtime error 26 ms 3440 KB Execution killed with signal 11
47 Runtime error 42 ms 5564 KB Execution killed with signal 11
48 Runtime error 37 ms 6792 KB Execution killed with signal 11
49 Runtime error 34 ms 4684 KB Execution killed with signal 11
50 Runtime error 43 ms 5748 KB Execution killed with signal 11
51 Runtime error 28 ms 3920 KB Execution killed with signal 11
52 Runtime error 36 ms 6856 KB Execution killed with signal 11
53 Runtime error 52 ms 6832 KB Execution killed with signal 11
54 Runtime error 34 ms 4544 KB Execution killed with signal 11
55 Runtime error 47 ms 6860 KB Execution killed with signal 11
56 Runtime error 44 ms 6736 KB Execution killed with signal 11
57 Runtime error 28 ms 3268 KB Execution killed with signal 11
58 Runtime error 43 ms 6840 KB Execution killed with signal 11
59 Runtime error 34 ms 4172 KB Execution killed with signal 11
60 Runtime error 54 ms 6760 KB Execution killed with signal 11
61 Runtime error 49 ms 6500 KB Execution killed with signal 11
62 Runtime error 52 ms 6808 KB Execution killed with signal 11
63 Runtime error 37 ms 6840 KB Execution killed with signal 11
64 Runtime error 57 ms 6820 KB Execution killed with signal 11
65 Runtime error 12 ms 2164 KB Execution killed with signal 11
66 Runtime error 37 ms 6840 KB Execution killed with signal 11
67 Runtime error 60 ms 6756 KB Execution killed with signal 11
68 Runtime error 40 ms 5580 KB Execution killed with signal 11
69 Runtime error 42 ms 5688 KB Execution killed with signal 11
70 Runtime error 48 ms 5980 KB Execution killed with signal 11
71 Runtime error 23 ms 3316 KB Execution killed with signal 11
72 Runtime error 43 ms 5260 KB Execution killed with signal 11
73 Runtime error 42 ms 5280 KB Execution killed with signal 11
74 Runtime error 44 ms 6796 KB Execution killed with signal 11
75 Runtime error 47 ms 6176 KB Execution killed with signal 11
76 Runtime error 58 ms 6836 KB Execution killed with signal 11
77 Runtime error 54 ms 6844 KB Execution killed with signal 11
78 Runtime error 56 ms 6796 KB Execution killed with signal 11
79 Runtime error 44 ms 6860 KB Execution killed with signal 11
80 Runtime error 44 ms 6868 KB Execution killed with signal 11
81 Runtime error 46 ms 6800 KB Execution killed with signal 11
82 Runtime error 45 ms 6836 KB Execution killed with signal 11
83 Runtime error 34 ms 6764 KB Execution killed with signal 11
84 Runtime error 44 ms 6772 KB Execution killed with signal 11
85 Runtime error 43 ms 6860 KB Execution killed with signal 11
86 Runtime error 27 ms 6772 KB Execution killed with signal 11
87 Runtime error 52 ms 6724 KB Execution killed with signal 11
88 Runtime error 43 ms 5624 KB Execution killed with signal 11
89 Runtime error 38 ms 6784 KB Execution killed with signal 11
90 Runtime error 43 ms 6796 KB Execution killed with signal 11
91 Runtime error 59 ms 6700 KB Execution killed with signal 11
92 Runtime error 36 ms 6828 KB Execution killed with signal 11
93 Runtime error 43 ms 6848 KB Execution killed with signal 11
94 Runtime error 37 ms 4560 KB Execution killed with signal 11
95 Runtime error 48 ms 6836 KB Execution killed with signal 11
96 Runtime error 44 ms 6864 KB Execution killed with signal 11
97 Runtime error 43 ms 5608 KB Execution killed with signal 11
98 Runtime error 54 ms 6836 KB Execution killed with signal 11
99 Runtime error 53 ms 6744 KB Execution killed with signal 11
100 Runtime error 35 ms 4812 KB Execution killed with signal 11
101 Runtime error 40 ms 6768 KB Execution killed with signal 11
102 Runtime error 30 ms 3892 KB Execution killed with signal 11