제출 #491800

#제출 시각아이디문제언어결과실행 시간메모리
491800Lawliet미술 수업 (IOI13_artclass)C++17
80 / 100
79 ms9080 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 510; struct Pixel { int r, g, b; Pixel(int red = 0, int green = 0, int blue = 0) : r(red), b(blue), g(green) {} int operator - (Pixel a) { int diff = abs(r - a.r); diff += abs(b - a.b); diff += abs(g - a.g); return diff; } }; int n, m; Pixel v[MAXN][MAXN]; int is1or4() { int qtdBad = 0; int c = 50; for(int i = 1 ; i <= n ; i++) { for(int j = 1 ; j <= m ; j++) { bool isBad = false; for(int x = max(i - 1,0) ; x<= i + 1 && x <= n ; x++) for(int y = max(j - 1,0) ; y <= j + 1 && y <= m ; y++) if( v[i][j] - v[x][y] > 50 ) isBad = true; if( isBad ) qtdBad++; } } return qtdBad; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { n = H; m = W; for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) v[i][j] = Pixel(R[i - 1][j - 1], G[i - 1][j - 1], B[i - 1][j - 1]); if( is1or4() <= (n*m)/3 ) { if( is1or4() <= 10000 ) return 4; return 1; } int sumGreen = 0, sumRed = 0, sumBlue = 0; for(int i = 1 ; i <= n ; i++) for(int j = 1 ; j <= m ; j++) sumGreen += v[i][j].g, sumRed += v[i][j].r, sumBlue += v[i][j].b; sumGreen /= n*m; sumRed /= n*m; sumBlue /= n*m; if( sumBlue + sumGreen + sumRed >= 300 ) return 3; return 2; }

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

artclass.cpp: In constructor 'Pixel::Pixel(int, int, int)':
artclass.cpp:10:15: warning: 'Pixel::b' will be initialized after [-Wreorder]
   10 |     int r, g, b;
      |               ^
artclass.cpp:10:12: warning:   'int Pixel::g' [-Wreorder]
   10 |     int r, g, b;
      |            ^
artclass.cpp:12:5: warning:   when initialized here [-Wreorder]
   12 |     Pixel(int red = 0, int green = 0, int blue = 0)
      |     ^~~~~
artclass.cpp: In function 'int is1or4()':
artclass.cpp:32:9: warning: unused variable 'c' [-Wunused-variable]
   32 |     int c = 50;
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...