제출 #845006

#제출 시각아이디문제언어결과실행 시간메모리
845006RaresFelix미술 수업 (IOI13_artclass)C++17
87 / 100
53 ms3496 KiB
#include "artclass.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; void add_dif_abs(int H, int W, int M[500][500], ll &dif_abs) { for(int i = 0; i < H; ++i) { for(int j = 0; j < W; ++j) { if(i + 1 < H) { dif_abs += abs(M[i][j] - M[i + 1][j]); } if(j + 1 < W) { dif_abs += abs(M[i][j] - M[i][j + 1]); } } } } void add_cont(int H, int W, int M[500][500], ll &cont, int vlim) { for(int i = 0; i < H; ++i) { for(int j = 0; j < W; ++j) { if(i + 1 < H) { cont += (abs(M[i][j] - M[i + 1][j]) > vlim); } if(j + 1 < W) { cont += (abs(M[i][j] - M[i][j + 1]) > vlim); } } } } ll contv(int H, int W, int R[500][500], int G[500][500], int B[500][500], int vlim) { ll cont = 0; add_cont(H, W, R, cont, vlim); add_cont(H, W, G, cont, vlim); add_cont(H, W, B, cont, vlim); return cont; } vector<pair<ld, ld> > Sem[] ={ {{7.46, 2.66}, {3.96, 1.68}, {6.71, 4.44}, {1.90, 0.82}, {11.02, 8.62}, }, {{11.24, 5.51}, {3.21, 3.63}, {14.82, 10.70}, {5.76, 3.15}, {0.82, 1.32}, }, {{22.17, 8.98}, {19.02, 8.88}, {36.50, 15.21}, {2.13, 0.49}, {24.87, 18.76}, }, {{1.71, 0.88}, {0.13, 0.15}, {0.43, 0.31}, {7.63, 8.53}, {0.07, 0.18} } }; ld W[5] = {1., .1, .1, 1., 1.}; ld asem(vector<pair<ld, ld> > A, vector<ld> V) { ld re = 0; for(int i = 0; i < 5; ++i) { ld deltasig = abs(V[i] - A[i].first) / A[i].second * W[i]; re += deltasig * deltasig * deltasig; } return re; } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { ll dif_abs = 0, cont40 = contv(H, W, R, G, B, 40), cont20 = contv(H, W, R, G, B, 20), cont100 = contv(H, W, R, G, B, 100); add_dif_abs(H, W, R, dif_abs); add_dif_abs(H, W, G, dif_abs); add_dif_abs(H, W, B, dif_abs); ld v1 = ld(dif_abs) / 1000000., v2 = ld(cont40) / 10000., v3 = ld(cont20) / 10000., v4 = v3 / v2, v5 = ld(cont100 / 1000.); vector<ld> V = {v1, v2, v3, v4, v5}; vector<ld> Sigma; for(int tip = 0; tip < 4; ++tip) { Sigma.push_back(asem(Sem[tip], V)); } const ld INF = 1e18; if(v1 > 5. || v2 > 1.) Sigma[3] = INF; if(v3 < 15. || v4 > 5. || v1 < 7. || v2 < 7.) Sigma[2] = INF; if(v2 * v3 < .9) Sigma[0] = Sigma[1] = Sigma[2] = INF; if(v4 > 3.5) Sigma[0] = INF; if(v4 < 2.) Sigma[1] = INF; int rasp = 0; for(int tip = 0; tip < 4; ++tip) { if(Sigma[tip] < Sigma[rasp]) rasp = tip; } // cout << rasp + 1 << " "; // for(int i = 0; i < 4; ++i) cout << fixed << setprecision(3) << Sigma[i] << " "; // cout << "\n"; // cout << fixed << setprecision(2) << v1 << " " << v2 << " " << v3 << " " << v4 << " " << v5 << "\n"; // cout << fixed << setprecision(2) << (ld(dif_abs) / 1000000.) << " " << (ld(cont40) / 10000.0) << " " << (ld(cont20) / 10000.0)<< " " << (ld(cont20) / ld(cont40)) << "\n"; return rasp + 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...