제출 #739670

#제출 시각아이디문제언어결과실행 시간메모리
739670yeyso미술 수업 (IOI13_artclass)C++14
87 / 100
55 ms6220 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; int style(int h, int w, int R[500][500], int G[500][500], int B[500][500]) { //return 2; vector<vector<int>> gr(h, vector<int>(w, 0)); vector<vector<int>> gg(h, vector<int>(w, 0)); vector<vector<int>> gb(h, vector<int>(w, 0)); vector<int> grd(500, 0); vector<int> grg(500, 0); vector<int> grb(500, 0); int mcir = 0; int mcig = 0; int mcib = 0; int noiser = 0; int noiseg = 0; int noiseb = 0; int productrgb = 1; int dr, dg, db; int white = 0; int black = 0; for(int i = 1; i < h; i ++){ for(int j = 1; j < w; j ++){ dr = 2 * R[i][j] - R[i-1][j] - R[i][j-1]; dg = 2 * G[i][j] - G[i-1][j] - G[i][j-1]; db = 2 * B[i][j] - B[i-1][j] - B[i][j-1]; if(R[i][j] > 200 and G[i][j] > 200 and B[i][j] > 200){ white += 1; } if(R[i][j] < 50 and G[i][j] < 50 and B[i][j] < 50){ black += 1; } gr[i][j] = dr; gg[i][j] = dg; gb[i][j] = db; grd[abs(dr)] += 1; grg[abs(dg)] += 1; grb[abs(db)] += 1; noiser += abs(dr); noiseg += abs(dg); noiseb += abs(db); } } noiser /= (h * w); noiseg /= (h * w); noiseb /= (h * w); vector<int> rfix = {0}; vector<int> gfix = {0}; vector<int> bfix = {0}; for(int i = 0; i < grd.size(); i ++){ rfix.push_back(rfix[rfix.size()-1] + grd[i]); gfix.push_back(gfix[gfix.size()-1] + grg[i]); bfix.push_back(rfix[bfix.size()-1] + grb[i]); } //for(int i = 0; i < rfix.size(); i ++){ //cout << grd[i] << " "; //} //cout << rfix[6] + gfix[6] + bfix[6]; //cout << white; //cout << noiser + noiseg + noiseb; if(rfix[6] + gfix[6] + bfix[6] > 200000){ // it's either style 1 (modern) or style 4 (landscape) if(white + black > 23000){ return 1; } else { return 4; } } else { // it's either style 2 (impressionist) or style 3 (modern 2) /*if(rfix[6] + gfix[6] + bfix[6] > 50000){ return 2; } else { return 3; }*/ if(noiser + noiseg + noiseb > 100){ return 3; } else { return 2; } } //return productrgb; /*for(int i = 0; i < grd.size(); i ++){ if(grd[i] > grd[mcir]){ mcir = i; } if(grg[i] > grg[mcig]){ mcig = i; } if(grb[i] > grb[mcib]){ mcib = i; } } if(mcir + mcig + mcib <= 3){ // it's either style 1 or 4 if(noiser + noiseg + noiseb < 17){ return 4; } else { return 1; } } else { if(noiser + noiseg + noiseb > 100){ return 3; } else { return 2; } }*/ //return mcir + mcig + mcib; //return max(1, min(4, mcir + mcig + mcib +1 )); //return noiser + noiseg + noiseb; } /* g++ -DEVAL -static -O2 -o artclass grader.c artclass.cpp */

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

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:56:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for(int i = 0; i < grd.size(); i ++){
      |                    ~~^~~~~~~~~~~~
artclass.cpp:15:9: warning: unused variable 'mcir' [-Wunused-variable]
   15 |     int mcir = 0;
      |         ^~~~
artclass.cpp:16:9: warning: unused variable 'mcig' [-Wunused-variable]
   16 |     int mcig = 0;
      |         ^~~~
artclass.cpp:17:9: warning: unused variable 'mcib' [-Wunused-variable]
   17 |     int mcib = 0;
      |         ^~~~
artclass.cpp:22:9: warning: unused variable 'productrgb' [-Wunused-variable]
   22 |     int productrgb = 1;
      |         ^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...