Submission #97591

#TimeUsernameProblemLanguageResultExecution timeMemory
97591georgerapeanuArt Class (IOI13_artclass)C++11
21 / 100
252 ms11436 KiB
#include "artclass.h" #include <cstdio> #include <set> #include <algorithm> #include <queue> using namespace std; const int dx[] = {-1,0,1,0}; const int dy[] = {0,1,0,-1}; set<pair<pair<int,int>,int> > s; bool viz[500][500]; double abs_gr(int a){ const double split = 200; const double split_val = 0.30; if(a <= split) return a / (split / split_val); return split_val + (1 - split_val) * (a - split) / (255 - split); } int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) { double averageR = 0; double averageG = 0; double averageB = 0; double area = 0; double absolutes = 0; for(int i = 0;i < H;i++){ for(int j = 0;j < W;j++){ s.insert(make_pair(make_pair(R[i][j],G[i][j]),B[i][j])); averageR += R[i][j]; averageG += G[i][j]; averageB += B[i][j]; absolutes += max(abs_gr(R[i][j]),max(abs_gr(G[i][j]),abs_gr(B[i][j]))); } } absolutes /= H; absolutes /= W; averageR /= H; averageR /= W; averageR /= 255.0; averageG /= H; averageG /= W; averageG /= 255.0; averageB /= H; averageB /= W; averageB /= 255.0; double average = (averageR + averageG + averageB) / 3.0; double averageRGB = (0.20 * averageR + 0.55 * averageG + 0.25 * averageB); double num = s.size(); if(absolutes >= 0.385){///1 and 4 if(average <= 0.59){ return 4; } else{ return 1; } } else{///2 and 3 if(average >= 0.40){ return 3; } else{ return 2; } } printf("%.6f ",num); printf("%.6f ",average); printf("%.6f ",averageR); printf("%.6f ",averageG); printf("%.6f ",averageB); printf("%.6f ",averageRGB); printf("%.6f ",absolutes); return -1; }

Compilation message (stderr)

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