제출 #651738

#제출 시각아이디문제언어결과실행 시간메모리
651738Lawliet미술 수업 (IOI13_artclass)C++17
54 / 100
64 ms22208 KiB
#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>red && green>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; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { l = H; c = W; 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 = 300; //min_qtd_greencomp = 8; min_sz_greencomp = ((l*c)/15); 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; } 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; // }

컴파일 시 표준 에러 (stderr) 메시지

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:135:8: warning: unused variable 'qtd_comp' [-Wunused-variable]
  135 |    int qtd_comp = aux.second;
      |        ^~~~~~~~
artclass.cpp:153:8: warning: unused variable 'qtd_green' [-Wunused-variable]
  153 |    int qtd_green = do_green_image();
      |        ^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...