Submission #805083

# Submission time Handle Problem Language Result Execution time Memory
805083 2023-08-03T12:56:10 Z ma_moutahid Art Class (IOI13_artclass) C++17
0 / 100
71 ms 29332 KB
#include <bits/stdc++.h>
#pragma once
using ll =long long;
ll LINF=1000000000000000000;
int INF=1000000000;
#define pi pair<int,int>
#define pl pair<ll,ll>
#define endl '\n'
#define vi vector<int>
#define vii vector<vector<int>>
#define vl vector<ll>
#define vll vector<vector<ll>>
#define int ll
using namespace std;

#include "artclass.h"

int margin;
int w,h;
vii g(500,vi(500)),b(500,vi(500)),r(500,vi(500));
int color=0;
vii id(500,vi(500));
bool compare_color(int i,int j,int x, int y){
    int R=r[i][j]-r[x][y];
    int B=b[i][j]-b[x][y];
    int G=g[i][j]-b[x][y];
    int diff=B*B+G*G+R*R;
    return diff<=margin*margin;
}
vii checked(500,vi(500));
void countcolor(int x,int y){
    if(checked[x][y])return;
    checked[x][y]=1;
    if(id[x][y]==0){
        color++;
        id[x][y]=color;
    }
    if(y+1<h){
        bool same= compare_color(x,y,x,y+1);
        if(same){
            id[x][y+1]=id[x][y];
        }
        countcolor(x,y+1);
    }
    if(x+1<w){
        bool same= compare_color(x,y,x+1,y);
        if(same){
            id[x+1][y]=id[x][y];
        }
        countcolor(x+1,y);
    }
}

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
    for(int i=0;i<500;i++)for(int j=0;j<500;j++)g[i][j]=G[i][j],b[i][j]=B[i][j],r[i][j]=R[i][j];
    h=H;
    w=W;
    int colors;
    int COLORS;
    //test 1: strict number of colors
    margin =2;
    countcolor(0,0);
    COLORS=color;
    //test 2: not so strict number of colors
    margin =6;
    id=vii(500,vi(500));
    countcolor(0,0);
    colors=color;

    //test 3 : how green
    int sum=0;
    for(int i=0;i<W;i++)for(int j=0;j<H;j++)sum+=G[i][j];
    sum/=h*H;

    int result=0;
    if(COLORS/colors<3){
        return 1;
    }
    if(colors<6)return 4;
    if(sum>150)return 2;
    return 3;
}

Compilation message

artclass.cpp:2:9: warning: #pragma once in main file
    2 | #pragma once
      |         ^~~~
artclass.cpp: In function 'll style(ll, ll, ll (*)[500], ll (*)[500], ll (*)[500])':
artclass.cpp:75:9: warning: unused variable 'result' [-Wunused-variable]
   75 |     int result=0;
      |         ^~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 52 ms 28644 KB Execution killed with signal 11
2 Runtime error 59 ms 29036 KB Execution killed with signal 11
3 Runtime error 53 ms 28052 KB Execution killed with signal 11
4 Runtime error 50 ms 28228 KB Execution killed with signal 11
5 Runtime error 27 ms 26888 KB Execution killed with signal 11
6 Runtime error 63 ms 28136 KB Execution killed with signal 11
7 Runtime error 52 ms 28380 KB Execution killed with signal 11
8 Runtime error 42 ms 25812 KB Execution killed with signal 11
9 Runtime error 41 ms 25604 KB Execution killed with signal 11
10 Runtime error 49 ms 28448 KB Execution killed with signal 11
11 Runtime error 44 ms 26160 KB Execution killed with signal 11
12 Runtime error 48 ms 26828 KB Execution killed with signal 11
13 Runtime error 50 ms 28500 KB Execution killed with signal 11
14 Runtime error 42 ms 27860 KB Execution killed with signal 11
15 Runtime error 54 ms 28876 KB Execution killed with signal 11
16 Runtime error 62 ms 28412 KB Execution killed with signal 11
17 Runtime error 43 ms 27800 KB Execution killed with signal 11
18 Runtime error 52 ms 27632 KB Execution killed with signal 11
19 Runtime error 49 ms 27360 KB Execution killed with signal 11
20 Runtime error 53 ms 28588 KB Execution killed with signal 11
21 Runtime error 50 ms 27144 KB Execution killed with signal 11
22 Runtime error 60 ms 28144 KB Execution killed with signal 11
23 Runtime error 36 ms 27532 KB Execution killed with signal 11
24 Runtime error 49 ms 27248 KB Execution killed with signal 11
25 Runtime error 37 ms 24672 KB Execution killed with signal 11
26 Runtime error 52 ms 26836 KB Execution killed with signal 11
27 Runtime error 53 ms 28848 KB Execution killed with signal 11
28 Runtime error 41 ms 27756 KB Execution killed with signal 11
29 Runtime error 40 ms 27820 KB Execution killed with signal 11
30 Runtime error 51 ms 26784 KB Execution killed with signal 11
31 Runtime error 55 ms 27052 KB Execution killed with signal 11
32 Runtime error 47 ms 26936 KB Execution killed with signal 11
33 Runtime error 50 ms 27232 KB Execution killed with signal 11
34 Runtime error 48 ms 28424 KB Execution killed with signal 11
35 Runtime error 51 ms 27680 KB Execution killed with signal 11
36 Runtime error 53 ms 28232 KB Execution killed with signal 11
37 Runtime error 32 ms 24132 KB Execution killed with signal 11
38 Runtime error 57 ms 29088 KB Execution killed with signal 11
39 Runtime error 45 ms 28252 KB Execution killed with signal 11
40 Runtime error 40 ms 27812 KB Execution killed with signal 11
41 Runtime error 48 ms 26752 KB Execution killed with signal 11
42 Runtime error 58 ms 27132 KB Execution killed with signal 11
43 Runtime error 57 ms 28992 KB Execution killed with signal 11
44 Runtime error 31 ms 23804 KB Execution killed with signal 11
45 Runtime error 48 ms 28276 KB Execution killed with signal 11
46 Runtime error 48 ms 27040 KB Execution killed with signal 11
47 Runtime error 49 ms 27356 KB Execution killed with signal 11
48 Runtime error 51 ms 27484 KB Execution killed with signal 11
49 Runtime error 43 ms 27960 KB Execution killed with signal 11
50 Runtime error 51 ms 28504 KB Execution killed with signal 11
51 Runtime error 55 ms 28752 KB Execution killed with signal 11
52 Runtime error 65 ms 29332 KB Execution killed with signal 11
53 Runtime error 60 ms 28372 KB Execution killed with signal 11
54 Runtime error 61 ms 28068 KB Execution killed with signal 11
55 Runtime error 55 ms 28564 KB Execution killed with signal 11
56 Runtime error 47 ms 26676 KB Execution killed with signal 11
57 Runtime error 48 ms 28376 KB Execution killed with signal 11
58 Runtime error 62 ms 26744 KB Execution killed with signal 11
59 Runtime error 42 ms 28104 KB Execution killed with signal 11
60 Runtime error 54 ms 28380 KB Execution killed with signal 11
61 Runtime error 27 ms 22164 KB Execution killed with signal 11
62 Runtime error 36 ms 24776 KB Execution killed with signal 11
63 Runtime error 46 ms 26776 KB Execution killed with signal 11
64 Runtime error 49 ms 26696 KB Execution killed with signal 11
65 Runtime error 43 ms 25804 KB Execution killed with signal 11
66 Runtime error 38 ms 24780 KB Execution killed with signal 11
67 Runtime error 63 ms 29072 KB Execution killed with signal 11
68 Runtime error 57 ms 27212 KB Execution killed with signal 11
69 Runtime error 56 ms 28400 KB Execution killed with signal 11
70 Runtime error 41 ms 27876 KB Execution killed with signal 11
71 Runtime error 57 ms 28852 KB Execution killed with signal 11
72 Runtime error 51 ms 28508 KB Execution killed with signal 11
73 Runtime error 58 ms 27672 KB Execution killed with signal 11
74 Runtime error 48 ms 26796 KB Execution killed with signal 11
75 Runtime error 62 ms 28844 KB Execution killed with signal 11
76 Runtime error 47 ms 28268 KB Execution killed with signal 11
77 Runtime error 38 ms 25136 KB Execution killed with signal 11
78 Runtime error 70 ms 29020 KB Execution killed with signal 11
79 Runtime error 61 ms 29108 KB Execution killed with signal 11
80 Runtime error 42 ms 28024 KB Execution killed with signal 11
81 Runtime error 42 ms 28048 KB Execution killed with signal 11
82 Runtime error 49 ms 28400 KB Execution killed with signal 11
83 Runtime error 31 ms 23852 KB Execution killed with signal 11
84 Runtime error 64 ms 29004 KB Execution killed with signal 11
85 Runtime error 60 ms 28492 KB Execution killed with signal 11
86 Runtime error 58 ms 27512 KB Execution killed with signal 11
87 Runtime error 51 ms 28324 KB Execution killed with signal 11
88 Runtime error 47 ms 26956 KB Execution killed with signal 11
89 Runtime error 49 ms 27312 KB Execution killed with signal 11
90 Runtime error 51 ms 28320 KB Execution killed with signal 11
91 Runtime error 50 ms 28440 KB Execution killed with signal 11
92 Runtime error 71 ms 29160 KB Execution killed with signal 11
93 Runtime error 57 ms 28988 KB Execution killed with signal 11
94 Runtime error 50 ms 28484 KB Execution killed with signal 11
95 Runtime error 56 ms 28916 KB Execution killed with signal 11
96 Runtime error 41 ms 25792 KB Execution killed with signal 11
97 Runtime error 35 ms 24780 KB Execution killed with signal 11
98 Runtime error 50 ms 28364 KB Execution killed with signal 11
99 Runtime error 57 ms 29092 KB Execution killed with signal 11
100 Runtime error 45 ms 27820 KB Execution killed with signal 11
101 Runtime error 50 ms 28484 KB Execution killed with signal 11
102 Runtime error 57 ms 28604 KB Execution killed with signal 11