Submission #844954

#TimeUsernameProblemLanguageResultExecution timeMemory
844954RaresFelixArt Class (IOI13_artclass)C++17
93 / 100
61 ms6276 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; } 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); 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; int rasp = 0; if(v1 < 4.) { rasp = 4; } else if(v1 > 27. || v3 > 30. || v1 * v2 > 27. * 10.) { rasp = 3; } else if(v4 < 3.) { rasp = 1; } else rasp = 2; //cout << fixed << setprecision(2) << rasp << " " << v1 << " " << v2 << " " << v3 << " " << v4 << "\n"; // cout << fixed << setprecision(2) << (ld(dif_abs) / 1000000.) << " " << (ld(cont40) / 10000.0) << " " << (ld(cont20) / 10000.0)<< " " << (ld(cont20) / ld(cont40)) << "\n"; return rasp; }
#Verdict Execution timeMemoryGrader output
Fetching results...