Submission #82668

#TimeUsernameProblemLanguageResultExecution timeMemory
82668zubecArt Class (IOI13_artclass)C++14
0 / 100
126 ms66560 KiB
#include "artclass.h"
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;

const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

const ld masOld[4] = {1513845.7449595534, 2878621.1179153402, 7651413.4723624049, 511293.3441765782};
const ld mas[4] = {1506183.0103572895, 2592183.2318885794, 8236725.3572605042, 481440.2991297710};

int a[510][510];

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++){
            a[i][j] = (R[i][j]<<16)+(G[i][j]<<8)+B[i][j];
        }
    }

    ld ans = 0;

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            for (int k = 0; k < 4; k++){
                int ii = i + dx[k], jj = j + dy[k];
                if (ii < 0 || jj < 0 || ii >= H || jj >= W)
                    continue;
                ans += abs(a[i][j]-a[ii][jj]);
            }
        }
    }
    ans /= (ld)(H*W);
    ld mn = 1e15;
    int intAns = 0;
    for (int i = 0; i < 4; i++){
        if (abs(ans-mas[i]) < mn){
            mn = abs(ans-mas[i]);
            intAns = i;
        }
    }
    return intAns+1;

}
#Verdict Execution timeMemoryGrader output
Fetching results...