# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1035647 | andrei_iorgulescu | Art Class (IOI13_artclass) | C++14 | 42 ms | 6224 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "artclass.h"
#include <bits/stdc++.h>
using namespace std;
int const_dif_lejer = 50;
int const_dif_hard = 20;
bool similar(int r1, int g1, int b1, int r2, int g2, int b2, int const_dif)
{
if (abs(r1 - r2) > const_dif or abs(g1 - g2) > const_dif or abs(b1 - b2) > const_dif)
return false;
return true;
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500])
{
vector<bool> could_be(5);
for (int i = 1; i <= 4; i++)
could_be[i] = true;
int cnt_nonculoare = 0,cnt_alb = 0,cnt_negru = 0;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
if (similar(R[i][j],G[i][j],B[i][j],0,0,0,const_dif_lejer))
cnt_negru++;
if (similar(R[i][j],G[i][j],B[i][j],255,255,255,const_dif_lejer))
cnt_alb++;
}
}
cnt_nonculoare = cnt_alb + cnt_negru;
double proc_alb = (double)cnt_alb / (double)(H * W);
double proc_negru = (double)cnt_negru / (double)(H * W);
double proc_nonculoare = (double)cnt_nonculoare / (double)(H * W);
int sum_R = 0, sum_G = 0, sum_B = 0;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
sum_R += R[i][j];
sum_G += G[i][j];
sum_B += B[i][j];
}
}
double proc_R = (double)sum_R / (double)(sum_R + sum_G + sum_B);
double proc_G = (double)sum_G / (double)(sum_R + sum_G + sum_B);
double proc_B = (double)sum_G / (double)(sum_R + sum_G + sum_B);
int cate_dom_G = 0,cate_dom_R = 0, cate_dom_B = 0;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
int r = R[i][j] - 20,g = G[i][j],b = B[i][j];
if (g > max(r,b) + 10)
cate_dom_G++;
if (r > max(g,b) + 10)
cate_dom_R++;
if (b > max(g,r) + 10)
cate_dom_B++;
}
}
double proc_dom_G = 0,proc_dom_R = 0,proc_dom_B = 0;
int sm_dom = cate_dom_R + cate_dom_G + cate_dom_B;
if (sm_dom != 0)
{
proc_dom_G = (double)cate_dom_G / (double)sm_dom;
proc_dom_R = (double)cate_dom_R / (double)sm_dom;
proc_dom_B = (double)cate_dom_B / (double)sm_dom;
}
//cout << setprecision(10) << fixed;
//cout << proc_dom_R << ' ' << proc_dom_G << ' ' << proc_dom_B << endl;
if (proc_alb >= 0.25d)
return 1;
if (proc_dom_G >= 0.7d)
return 2;
if (proc_dom_R >= 0.9d)
return 4;
if (proc_dom_B <= 0.1d)
return 2;
return 3;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |