Submission #1155625

#TimeUsernameProblemLanguageResultExecution timeMemory
1155625alexddArt Class (IOI13_artclass)C++20
100 / 100
34 ms6376 KiB
#include "artclass.h"
#include<bits/stdc++.h>
using namespace std;
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,-1,1};

int H,W;
int R[505][505],G[505][505],B[505][505];
bool visited[505][505];
int DIFF = 30;
bool similar(int ax, int ay, int bx, int by)
{
    if(abs(R[ax][ay]-R[bx][by]) + abs(G[ax][ay]-G[bx][by]) + abs(B[ax][ay]-B[bx][by]) <= DIFF)
        return 1;
    return 0;
}
int sum_vec_dif()
{
    int sum=0,cnt=0;
    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(i+1<=H)
                cnt++,sum+=abs(R[i][j]-R[i+1][j]) + abs(G[i][j]-G[i+1][j]) + abs(B[i][j]-B[i+1][j]);
            if(j+1<=W && !similar(i,j,i,j+1))
                cnt++,sum+=abs(R[i][j]-R[i][j+1]) + abs(G[i][j]-G[i][j+1]) + abs(B[i][j]-B[i][j+1]);
        }
    }
    return sum / cnt;
}
int style(int cit_H, int cit_W, int cit_R[500][500], int cit_G[500][500], int cit_B[500][500])
{
    H = cit_H;
    W = cit_W;
    for(int i=1;i<=H;i++)
    {
        for(int j=1;j<=W;j++)
        {
            R[i][j] = cit_R[i-1][j-1];
            G[i][j] = cit_G[i-1][j-1];
            B[i][j] = cit_B[i-1][j-1];
        }
    }
    int x = sum_vec_dif();
    if(x <= 12)
        return 4;
    if(x <= 30)
        return 1;
    if(x >= 75)
        return 3;
    return 2;
}
#Verdict Execution timeMemoryGrader output
Fetching results...