답안 #651741

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
651741 2022-10-19T23:15:29 Z Lawliet 미술 수업 (IOI13_artclass) C++17
0 / 100
52 ms 6420 KB
#include "artclass.h"
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
 
using namespace std;
 
int l, c;
 
int min_sz_comp;
int min_bigcomp;
int min_bigcomp_group14;
int min_qtd_green;
int min_dif;
int min_colors_sum;
int min_qtd_greencomp;
int min_sz_greencomp;
 
struct pixel{
   int red, green, blue;
   pixel(int r = 0, int g = 0, int b = 0){
       red = r;
       green = g;
       blue = b;
   }
  
   bool operator == (pixel b){
       int red_dif = abs((*this).red - b.red);
       int green_dif = abs((*this).green - b.green);
       int blue_dif = abs((*this).blue - b.blue);
       return (red_dif<=min_dif && green_dif<=min_dif && blue_dif<=min_dif);
   }
  
   bool isGreen(){
       int sum = red + green + blue;
       return ((green+6>red && green+6>blue) && sum<min_colors_sum);
   }
};
 
pixel image[510][510];
bool green_image[510][510];
int marc[510][510];
 
int dl[] = {-1, 0, 1, 0};
int dc[] = {0, 1, 0, -1};
 
int find_comp(int li, int ci){
   int qtd_pixel = 1;
   marc[li][ci] = 1;
   for(int i=0;i<4;i++){
       int vizl = li + dl[i];
       int vizc = ci + dc[i];
       if(vizl<0 || vizl>l-1) continue;
       if(vizc<0 || vizc>c-1) continue;
       if(marc[vizl][vizc] == 1) continue;
       if(image[vizl][vizc] == image[li][ci]) qtd_pixel += find_comp(vizl, vizc);
   }
   return qtd_pixel;
}
 
pair<int, int> find_bigcomp(){
   memset(marc, 0, sizeof(marc));
   int qtd_bigcomp_ = 0;
   int qtd_comp_ = 0;
   for(int i=0;i<l;i++){
       for(int j=0;j<c;j++){
           if(marc[i][j] == 0){
               int sz_comp = find_comp(i, j);
               qtd_comp_++;
               if(sz_comp>min_sz_comp) qtd_bigcomp_++;
           }
       }
   }
   return {qtd_bigcomp_, qtd_comp_};
}
 
int do_green_image(){
   int qtd_green_ = 0;
   for(int i=0;i<l;i++){
       for(int j=0;j<c;j++){
           green_image[i][j] = image[i][j].isGreen();
           qtd_green_ += green_image[i][j];
       }
   }
   return qtd_green_;
}
 
int marc_greencomp(int li, int ci){
   int sz_greencomp = 1;
   marc[li][ci] = 1;
   for(int i=0;i<4;i++){
       int vizl = li + dl[i];
       int vizc = ci + dc[i];
       if(vizl<0 || vizl>l-1) continue;
       if(vizc<0 || vizc>c-1) continue;
       if(marc[vizl][vizc] == 1) continue;
       if(green_image[vizl][vizc]) sz_greencomp += marc_greencomp(vizl, vizc);
   }
   return sz_greencomp;
}
 
int find_greencomp(){
//    memset(marc, 0, sizeof(marc));
//    int max_sz_greencomp = 0;
//    int qtd_greencomp_ = 0;
//    for(int i=0;i<l;i++){
//        for(int j=0;j<c;j++){
//            if(marc[i][j] == 0 && green_image[i][j]){
//                max_sz_greencomp = max(max_sz_greencomp, marc_greencomp(i, j));
//                qtd_greencomp_++;
//            }
//        }
//    }
//    return max_sz_greencomp;
    memset(marc, 0, sizeof(marc));
   int mx = 0;
   for(int i=0;i<l;i++){
       for(int j=0;j<c;j++){
           if(marc[i][j] == 0){
                mx = max(mx, find_comp(i,j));
            //    int sz_comp = find_comp(i, j);
            //    qtd_comp_++;
            //    if(sz_comp>min_sz_comp) qtd_bigcomp_++;
           }
       }
   }

   return mx;
}
 
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
   l = H;
   c = W;
   return 1;
   min_sz_comp = ((l*c)/22);
   min_bigcomp = 1;
   min_bigcomp_group14 = 6;
   //min_qtd_green = ((l*c)/4);
   min_dif = 5;
   min_colors_sum = 350;
   //min_qtd_greencomp = 8;
   min_sz_greencomp = ((l*c)/30);
   for(int i=0;i<l;i++){
       for(int j=0;j<c;j++){
           image[i][j] = pixel(R[i][j], G[i][j], B[i][j]);
       }
   }
   pair<int, int> aux = find_bigcomp();
   int qtd_bigcomp = aux.first;
   int qtd_comp = aux.second;

//    cout << qtd_bigcomp << endl;
 
   if(qtd_bigcomp>min_bigcomp){
        for(int i = 0 ; i < l ; i++)
        {
            for(int j = 0 ; j < c ; j++)
            {
                int sum = R[i][j] + G[i][j] + B[i][j];
                if( sum < 80 )
                    return 1;
            }
        }
        return 4;
   }
  
    min_dif=10;
  
   int qtd_green = do_green_image();
   /*if(qtd_green<min_qtd_green){
       return 3;
   }*/
  
   int max_sz_greencomp = find_greencomp();
   if(max_sz_greencomp>min_sz_greencomp) return 2;
   else return 3;
   /*if(qtd_greencomp<min_qtd_greencomp) return 2;
   else return 3;*/
  
}
 
// int r[500][500], g[500][500], b[500][500];
 
// int main()
// {
//    int n, m;
//    cin >> n >> m;
 
//    for(int i = 0 ; i < n ; i++)
//        for(int j = 0 ; j < m ; j++)
//            cin >> r[i][j] >> g[i][j] >> b[i][j];
 
//    cout << style(n, m, r, g, b) << endl;
// }

Compilation message

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:150:8: warning: unused variable 'qtd_comp' [-Wunused-variable]
  150 |    int qtd_comp = aux.second;
      |        ^~~~~~~~
artclass.cpp:169:8: warning: unused variable 'qtd_green' [-Wunused-variable]
  169 |    int qtd_green = do_green_image();
      |        ^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 6212 KB Output isn't correct
2 Incorrect 30 ms 6220 KB Output isn't correct
3 Incorrect 36 ms 5640 KB Output isn't correct
4 Incorrect 44 ms 6192 KB Output isn't correct
5 Incorrect 31 ms 5076 KB Output isn't correct
6 Incorrect 39 ms 5796 KB Output isn't correct
7 Incorrect 26 ms 4820 KB Output isn't correct
8 Incorrect 31 ms 5196 KB Output isn't correct
9 Incorrect 40 ms 5656 KB Output isn't correct
10 Incorrect 42 ms 5840 KB Output isn't correct
11 Incorrect 39 ms 6352 KB Output isn't correct
12 Incorrect 38 ms 5604 KB Output isn't correct
13 Correct 35 ms 6164 KB Output is correct
14 Incorrect 31 ms 6276 KB Output isn't correct
15 Incorrect 42 ms 6164 KB Output isn't correct
16 Incorrect 45 ms 6112 KB Output isn't correct
17 Correct 50 ms 6220 KB Output is correct
18 Incorrect 41 ms 5880 KB Output isn't correct
19 Incorrect 34 ms 6228 KB Output isn't correct
20 Incorrect 41 ms 5784 KB Output isn't correct
21 Incorrect 37 ms 5460 KB Output isn't correct
22 Incorrect 25 ms 4760 KB Output isn't correct
23 Incorrect 38 ms 6220 KB Output isn't correct
24 Incorrect 40 ms 6376 KB Output isn't correct
25 Incorrect 30 ms 5116 KB Output isn't correct
26 Incorrect 43 ms 5672 KB Output isn't correct
27 Correct 46 ms 6216 KB Output is correct
28 Incorrect 35 ms 6360 KB Output isn't correct
29 Incorrect 41 ms 6224 KB Output isn't correct
30 Incorrect 36 ms 5540 KB Output isn't correct
31 Incorrect 34 ms 5268 KB Output isn't correct
32 Incorrect 13 ms 6228 KB Output isn't correct
33 Incorrect 23 ms 4628 KB Output isn't correct
34 Correct 38 ms 6172 KB Output is correct
35 Correct 46 ms 6276 KB Output is correct
36 Incorrect 36 ms 6276 KB Output isn't correct
37 Incorrect 34 ms 6220 KB Output isn't correct
38 Incorrect 40 ms 6228 KB Output isn't correct
39 Incorrect 47 ms 6220 KB Output isn't correct
40 Incorrect 38 ms 5432 KB Output isn't correct
41 Incorrect 27 ms 4812 KB Output isn't correct
42 Incorrect 38 ms 6212 KB Output isn't correct
43 Incorrect 39 ms 6248 KB Output isn't correct
44 Incorrect 38 ms 5636 KB Output isn't correct
45 Correct 26 ms 4964 KB Output is correct
46 Correct 40 ms 6420 KB Output is correct
47 Incorrect 41 ms 5844 KB Output isn't correct
48 Correct 26 ms 6244 KB Output is correct
49 Incorrect 43 ms 6200 KB Output isn't correct
50 Incorrect 33 ms 6160 KB Output isn't correct
51 Incorrect 40 ms 5636 KB Output isn't correct
52 Incorrect 39 ms 6192 KB Output isn't correct
53 Correct 43 ms 5844 KB Output is correct
54 Incorrect 31 ms 6180 KB Output isn't correct
55 Incorrect 42 ms 5784 KB Output isn't correct
56 Correct 48 ms 6224 KB Output is correct
57 Incorrect 34 ms 6240 KB Output isn't correct
58 Incorrect 28 ms 4728 KB Output isn't correct
59 Incorrect 39 ms 6184 KB Output isn't correct
60 Incorrect 40 ms 6228 KB Output isn't correct
61 Incorrect 37 ms 6276 KB Output isn't correct
62 Incorrect 11 ms 3940 KB Output isn't correct
63 Incorrect 39 ms 6188 KB Output isn't correct
64 Incorrect 39 ms 5760 KB Output isn't correct
65 Incorrect 21 ms 4564 KB Output isn't correct
66 Incorrect 37 ms 5524 KB Output isn't correct
67 Correct 32 ms 6212 KB Output is correct
68 Incorrect 36 ms 5528 KB Output isn't correct
69 Correct 49 ms 6252 KB Output is correct
70 Incorrect 30 ms 6228 KB Output isn't correct
71 Correct 46 ms 6156 KB Output is correct
72 Correct 48 ms 6220 KB Output is correct
73 Correct 48 ms 6272 KB Output is correct
74 Incorrect 40 ms 6224 KB Output isn't correct
75 Correct 43 ms 6216 KB Output is correct
76 Incorrect 39 ms 5768 KB Output isn't correct
77 Incorrect 40 ms 6244 KB Output isn't correct
78 Correct 46 ms 6184 KB Output is correct
79 Correct 47 ms 6164 KB Output is correct
80 Incorrect 39 ms 6268 KB Output isn't correct
81 Incorrect 35 ms 6216 KB Output isn't correct
82 Correct 41 ms 6268 KB Output is correct
83 Incorrect 38 ms 6168 KB Output isn't correct
84 Incorrect 41 ms 6220 KB Output isn't correct
85 Incorrect 32 ms 5216 KB Output isn't correct
86 Incorrect 45 ms 6320 KB Output isn't correct
87 Incorrect 31 ms 6236 KB Output isn't correct
88 Incorrect 38 ms 5488 KB Output isn't correct
89 Incorrect 37 ms 5584 KB Output isn't correct
90 Correct 47 ms 6196 KB Output is correct
91 Incorrect 39 ms 5688 KB Output isn't correct
92 Incorrect 25 ms 6192 KB Output isn't correct
93 Incorrect 35 ms 5392 KB Output isn't correct
94 Correct 49 ms 6220 KB Output is correct
95 Incorrect 39 ms 5772 KB Output isn't correct
96 Incorrect 20 ms 4440 KB Output isn't correct
97 Correct 52 ms 6188 KB Output is correct
98 Correct 47 ms 6236 KB Output is correct
99 Incorrect 45 ms 6172 KB Output isn't correct
100 Incorrect 39 ms 5696 KB Output isn't correct
101 Incorrect 38 ms 5580 KB Output isn't correct
102 Incorrect 37 ms 5532 KB Output isn't correct