제출 #401611

#제출 시각아이디문제언어결과실행 시간메모리
401611rqi미술 수업 (IOI13_artclass)C++14
89 / 100
104 ms12892 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; typedef long double db; #define mp make_pair #define f first #define s second #define pb push_back int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; int H; int W; int col[500][500][3]; db avg_diff[500][500]; db getContrast(){ db avg_tot = 0; int avg_num = 0; for(int i = 1; i+1 < H; i++){ for(int j = 1; j+1 < W; j++){ db tot_diff = 0; for(int dir = 0; dir < 8; dir++){ for(int k = 0; k < 3; k++){ tot_diff+=abs(col[i][j][k]-col[i+dx[dir]][j+dy[dir]][k]); } } avg_diff[i][j] = tot_diff/db(8*3); avg_tot+=avg_diff[i][j]; avg_num++; } } return avg_tot/avg_num; } pair<db, db> contrast_rang[4] = {mp(3.19, 11.8), mp(8.8, 20.3), mp(21.3, 42.9), mp(1.43, 3.3)}; db score[4]; db getPropOff(pair<db, db> a, db b){ db a_mid = (a.f+a.s)/2; db a_diff = (a.s-a_mid); return abs(b-a_mid)/a_diff; } 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++){ col[i][j][0] = _R[i][j]; col[i][j][1] = _G[i][j]; col[i][j][2] = _B[i][j]; } } db contrast = getContrast(); //cout << contrast << "\n"; for(int i = 0; i < 4; i++){ score[i] = 1.0/getPropOff(contrast_rang[i], contrast); } vector<pair<db, int>> sorted_scores; for(int i = 0; i < 4; i++){ sorted_scores.pb(mp(score[i], i)); } sort(sorted_scores.rbegin(), sorted_scores.rend()); return sorted_scores[0].s+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...