답안 #585020

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
585020 2022-06-28T09:00:56 Z benson1029 미술 수업 (IOI13_artclass) C++14
89 / 100
81 ms 19120 KB
#include "artclass.h"
#include <bits/stdc++.h>
using namespace std;

int h,w;
bool vis[500][500];
int v[500][500][3];
double avg[500][500][3];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};

bool valid(int x, int y) {
    return (x>=0&&y>=0&&x<h&&y<w);
}

bool near(int X1, int Y1, int X2, int Y2) {
    return (abs(v[X1][Y1][0]-v[X2][Y2][0]) + abs(v[X1][Y1][1]-v[X2][Y2][1]) + abs(v[X1][Y1][2]-v[X2][Y2][2])) <= 20;
}

bool near2(int X1, int Y1, int X2, int Y2) {
    return (abs(v[X1][Y1][0]-v[X2][Y2][0]) + abs(v[X1][Y1][1]-v[X2][Y2][1]) + abs(v[X1][Y1][2]-v[X2][Y2][2])) <= 10;
}

void dfs(int x, int y) {
    vis[x][y] = true;
    for(int i=0; i<4; i++) {
        if(!valid(x+dx[i], y+dy[i])) continue;
        if(vis[x+dx[i]][y+dy[i]]) continue;
        if(near(x, y, x+dx[i], y+dy[i])) {
            dfs(x+dx[i], y+dy[i]);
        }
    }
}

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
    h = H;
    w = W;
    for(int i=0; i<h; i++) for(int j=0; j<w; j++) {
        v[i][j][0] = R[i][j];
        v[i][j][1] = G[i][j];
        v[i][j][2] = B[i][j];
    }
    int connected_component = 0;
    for(int i=0; i<h; i++) for(int j=0; j<w; j++) {
        if(!vis[i][j]) {
            dfs(i, j);
            connected_component++;
        }
    }
    double r,g,b;
    int cntg = 0;
    for(int i=0; i<h; i++) for(int j=0; j<w; j++) {
        r += R[i][j];
        g += G[i][j];
        b += B[i][j];
        if(G[i][j]-60 > B[i][j] && G[i][j]+10 > R[i][j]) cntg++;
    }
    if(g > r && g > b) cntg += 100000;
    int cntsame = 0;
    for(int i=0; i<h; i++) {
        for(int j=0; j<w; j++) {
            if(i>=3 && near2(i, j, i-3, j)) cntsame++;
            if(j>=3 && near2(i, j, i, j-3)) cntsame++;
        }
    }
    //cout << connected_component << " " << cntg << " " << cntsame << "\n";
    if(connected_component <= 1000) return 4;
    if(cntsame>100000) return 1;
    if(cntg > 4000) return 2;
    if(connected_component <= 20000) return 2;
    return 3;
}

Compilation message

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:58:14: warning: 'g' may be used uninitialized in this function [-Wmaybe-uninitialized]
   58 |     if(g > r && g > b) cntg += 100000;
      |        ~~~~~~^~~~~~~~
artclass.cpp:58:14: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
artclass.cpp:58:5: warning: 'r' may be used uninitialized in this function [-Wmaybe-uninitialized]
   58 |     if(g > r && g > b) cntg += 100000;
      |     ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 9436 KB Output is correct
2 Correct 54 ms 5452 KB Output is correct
3 Correct 33 ms 3416 KB Output is correct
4 Correct 49 ms 4836 KB Output is correct
5 Correct 51 ms 5348 KB Output is correct
6 Correct 34 ms 3456 KB Output is correct
7 Correct 47 ms 5132 KB Output is correct
8 Correct 58 ms 6768 KB Output is correct
9 Correct 54 ms 5568 KB Output is correct
10 Correct 53 ms 5964 KB Output is correct
11 Incorrect 52 ms 12748 KB Output isn't correct
12 Correct 54 ms 6896 KB Output is correct
13 Correct 33 ms 3352 KB Output is correct
14 Correct 66 ms 6396 KB Output is correct
15 Incorrect 60 ms 7592 KB Output isn't correct
16 Correct 13 ms 1476 KB Output is correct
17 Correct 40 ms 4360 KB Output is correct
18 Correct 61 ms 8560 KB Output is correct
19 Correct 54 ms 5412 KB Output is correct
20 Correct 57 ms 6320 KB Output is correct
21 Correct 48 ms 10200 KB Output is correct
22 Correct 60 ms 9220 KB Output is correct
23 Correct 46 ms 8176 KB Output is correct
24 Correct 40 ms 8800 KB Output is correct
25 Correct 55 ms 11928 KB Output is correct
26 Correct 53 ms 5724 KB Output is correct
27 Correct 60 ms 8372 KB Output is correct
28 Correct 63 ms 6916 KB Output is correct
29 Correct 53 ms 19120 KB Output is correct
30 Correct 49 ms 6380 KB Output is correct
31 Correct 40 ms 3964 KB Output is correct
32 Correct 19 ms 7332 KB Output is correct
33 Correct 61 ms 6444 KB Output is correct
34 Correct 53 ms 5316 KB Output is correct
35 Correct 43 ms 9420 KB Output is correct
36 Correct 50 ms 7364 KB Output is correct
37 Incorrect 50 ms 9688 KB Output isn't correct
38 Correct 51 ms 6828 KB Output is correct
39 Correct 48 ms 12776 KB Output is correct
40 Correct 52 ms 9828 KB Output is correct
41 Correct 55 ms 7944 KB Output is correct
42 Correct 37 ms 4088 KB Output is correct
43 Incorrect 41 ms 8920 KB Output isn't correct
44 Correct 55 ms 5196 KB Output is correct
45 Correct 30 ms 2764 KB Output is correct
46 Correct 56 ms 9568 KB Output is correct
47 Correct 61 ms 8980 KB Output is correct
48 Correct 49 ms 4812 KB Output is correct
49 Correct 53 ms 8272 KB Output is correct
50 Correct 48 ms 6336 KB Output is correct
51 Correct 42 ms 4092 KB Output is correct
52 Correct 39 ms 6388 KB Output is correct
53 Correct 56 ms 7496 KB Output is correct
54 Correct 69 ms 6696 KB Output is correct
55 Correct 59 ms 7064 KB Output is correct
56 Incorrect 51 ms 6348 KB Output isn't correct
57 Incorrect 46 ms 4792 KB Output isn't correct
58 Correct 55 ms 12024 KB Output is correct
59 Correct 47 ms 5488 KB Output is correct
60 Correct 51 ms 9508 KB Output is correct
61 Correct 46 ms 4932 KB Output is correct
62 Correct 52 ms 6636 KB Output is correct
63 Correct 57 ms 7948 KB Output is correct
64 Correct 55 ms 13200 KB Output is correct
65 Correct 49 ms 5708 KB Output is correct
66 Incorrect 59 ms 4776 KB Output isn't correct
67 Incorrect 69 ms 9768 KB Output isn't correct
68 Correct 50 ms 5160 KB Output is correct
69 Correct 55 ms 6504 KB Output is correct
70 Correct 58 ms 7172 KB Output is correct
71 Correct 62 ms 7596 KB Output is correct
72 Correct 51 ms 5384 KB Output is correct
73 Correct 68 ms 5484 KB Output is correct
74 Correct 48 ms 4940 KB Output is correct
75 Correct 52 ms 6616 KB Output is correct
76 Incorrect 74 ms 8884 KB Output isn't correct
77 Correct 33 ms 7276 KB Output is correct
78 Correct 39 ms 7112 KB Output is correct
79 Correct 56 ms 5340 KB Output is correct
80 Correct 24 ms 2688 KB Output is correct
81 Incorrect 69 ms 6348 KB Output isn't correct
82 Correct 56 ms 16592 KB Output is correct
83 Correct 50 ms 5080 KB Output is correct
84 Correct 46 ms 9804 KB Output is correct
85 Correct 58 ms 6404 KB Output is correct
86 Incorrect 53 ms 8652 KB Output isn't correct
87 Correct 51 ms 6348 KB Output is correct
88 Correct 81 ms 15688 KB Output is correct
89 Correct 42 ms 4396 KB Output is correct
90 Incorrect 57 ms 8400 KB Output isn't correct
91 Correct 52 ms 5636 KB Output is correct
92 Correct 37 ms 6332 KB Output is correct
93 Incorrect 54 ms 11748 KB Output isn't correct
94 Correct 42 ms 4652 KB Output is correct
95 Incorrect 47 ms 5904 KB Output isn't correct
96 Correct 57 ms 8452 KB Output is correct
97 Incorrect 51 ms 5336 KB Output isn't correct
98 Correct 63 ms 9776 KB Output is correct
99 Correct 33 ms 3320 KB Output is correct
100 Correct 54 ms 6476 KB Output is correct
101 Correct 28 ms 2804 KB Output is correct
102 Correct 42 ms 6356 KB Output is correct