제출 #651717

#제출 시각아이디문제언어결과실행 시간메모리
651717LucaGreg미술 수업 (IOI13_artclass)C++17
5 / 100
70 ms25132 KiB
#include <bits/stdc++.h> using namespace std; #include "artclass.h" 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; 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_; } void marc_greencomp(int li, int ci){ 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]) marc_greencomp(vizl, vizc); } } int find_greencomp(){ memset(marc, 0, sizeof(marc)); int qtd_greencomp_ = 0; for(int i=0;i<l;i++){ for(int j=0;j<c;j++){ if(marc[i][j] == 0){ marc_greencomp(i, j); qtd_greencomp_++; } } } return qtd_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)/20); min_bigcomp = 2; min_bigcomp_group14 = 5; min_qtd_green = ((l*c)/25); min_dif = 15; min_colors_sum = 310; min_qtd_greencomp = 5; 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; if(qtd_bigcomp>min_bigcomp){ if(qtd_bigcomp<min_bigcomp_group14) return 4; else return 1; } int qtd_green = do_green_image(); if(qtd_green<min_qtd_green){ return 3; } int qtd_greencomp = find_greencomp(); if(qtd_greencomp<min_qtd_greencomp) return 2; else return 3; }

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

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