Submission #776997

#TimeUsernameProblemLanguageResultExecution timeMemory
776997caganyanmazArt Class (IOI13_artclass)C++17
100 / 100
111 ms6536 KiB
#include "artclass.h"
#include <bits/stdc++.h>
using namespace std;

constexpr static int MXSIZE = 500;
constexpr static int CHANNEL = 3;
array<int, 3> image[MXSIZE][MXSIZE];
constexpr static int MINDIFF = 10;
const static double FAC = 0.00392156862;
const static double WHITE_T = 0.65;
const static double BRIGHT_T = 0.7;

int style(int H, int W, int R[500][500], int G[500][500], int B[500][500])
{
        for (int i = 0; i < H; i++)
                for (int j = 0; j < W; j++)
                        image[i][j] = {R[i][j], G[i][j], B[i][j]};
        int64_t vc = 0;
        int64_t hc = 0;
        array<int64_t,3> tc ({0, 0, 0});
        double sum_y = 0;
        int white = 0;
        int green = 0;
        int blue = 0;
        for (int i = 0; i < H-1; i++)
        {
                for (int j = 0; j < W-1; j++)
                {
                        for (int c = 0; c < CHANNEL; c++)
                        {
                                vc += abs(image[i][j][c] - image[i+1][j][c]);
                                hc += abs(image[i][j][c] - image[i][j+1][c]);
                        }
                        double r = image[i][j][0] * FAC, g = image[i][j][1] * FAC, b = image[i][j][2] * FAC;
                        if ((r > WHITE_T) && (g > WHITE_T) && (b > WHITE_T))
                                white++;
                        if ((g - b) > 0.2)
                                green++;
                        if (b > g)
                                blue++;
                }
        }
        int64_t total_size = H*W;
        int64_t change = vc + hc;
        int difference = change / total_size;
        double white_r = (double)white / total_size;
        double d = (double)difference * FAC;
        double blue_r = (double)blue / total_size;
        double green_r = (double)green / total_size;
        double diff = blue_r - green_r;
        double eval = max(diff, 0.0) + white_r;
        if (difference <= 15)
                return 4;
        if (difference > 100)
                return 3;
        if (eval > 0.25)
                return 1;
        return 2;
}

Compilation message (stderr)

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:21:16: warning: unused variable 'sum_y' [-Wunused-variable]
   21 |         double sum_y = 0;
      |                ^~~~~
artclass.cpp:47:16: warning: unused variable 'd' [-Wunused-variable]
   47 |         double d = (double)difference * FAC;
      |                ^
#Verdict Execution timeMemoryGrader output
Fetching results...