제출 #395661

#제출 시각아이디문제언어결과실행 시간메모리
395661ly20미술 수업 (IOI13_artclass)C++17
96 / 100
108 ms6276 KiB
#include "artclass.h" #include <bits/stdc++.h> #define ll long long using namespace std ; int H , W ; int r[510][510] , g[510][510] , b[510][510] ; int dx[2] = {0,1} , dy[2] = {1,0} ; bool valid(int x, int y) { return 0 <= min(x,y) && x < H && y < W ; } int getDiff(int x1, int y1, int x2, int y2) { int dr = abs(r[x1][y1]-r[x2][y2]) ; int dg = abs(g[x1][y1]-g[x2][y2]) ; int db = abs(b[x1][y1]-b[x2][y2]) ; return dr+dg+db ; } bool isWhite(int x, int y ) { bool ok = max({ abs(r[x][y]-g[x][y]) , abs(g[x][y]-b[x][y]) , abs(r[x][y]-b[x][y]) }) <= 15 ; ok &= min({r[x][y] , g[x][y], b[x][y]}) >= 185 ; return ok ; } bool isGreen(int x, int y) { return max(b[x][y],r[x][y]) + 35 <= g[x][y] && !isWhite(x,y) ; } 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++ ) { r[i][j]= R[i][j] ; g[i][j] = G[i][j] ; b[i][j] = B[i][j] ; } int mnDiff = INT_MAX ; int mxDiff = -INT_MAX ; double s = 0 , s_squared = 0 ; double cnt = 0 ; double qtd[2] = {0,0} ; for(int i = 0 ; i < H ; i++ ) for(int j = 0 ; j < W ; j++ ) { if(isWhite(i,j)) qtd[0]++ ; if( isGreen(i,j) ) qtd[1]++ ; for(int a = 0 , ni , nj ; a < 2 ; a++ ) { ni = i + dx[a] ; nj = j+dy[a] ; if(!valid(ni,nj)) continue ; cnt++ ; mnDiff = min(mnDiff, getDiff(i,j,ni,nj)) ; mxDiff = max( mxDiff, getDiff(i,j,ni,nj) ) ; s += getDiff(i,j,ni,nj) ; } } s /= cnt ; qtd[0] /= (double)(H*W) ; qtd[1] /= (double)(H*W) ; if( s <= 9.0 ) return 4 ; if(s >= 50.0 ) return 3 ; if(s >= 25.0 ) return 2 ; if( qtd[0] <= 0.12 ) return 2 ; return 1 ; }

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

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:44:17: warning: unused variable 's_squared' [-Wunused-variable]
   44 |  double s = 0 , s_squared = 0 ;
      |                 ^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...