# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
155924 | qkxwsm | Art Class (IOI13_artclass) | C++14 | 94 ms | 9584 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;
template<class T, class U>
void ckmin(T &a, U b)
{
if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
if (a < b) a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef pair<ld, ld> pdd;
typedef vector<vector<array<int, 3> > > img;
int ans;
img grid;
pdd vals[4] = {{2881.44,61.10}, {6595.89,102.41}, {7891.44,279.11}, {2518.33,19.34}};
ld co;
pdd calc(img f)
{
//{# of distinct colors, average blackness}
pdd res = {0, 0};
set<array<int, 3> > s;
FOR(i, 0, 100)
{
FOR(j, 0, 100)
{
array<int, 3> cur = f[i][j];
// FOR(k, 0, 3) cur[i] /= 10;
s.insert(cur);
}
}
FOR(i, 1, SZ(f))
{
FOR(j, 1, SZ(f[i]))
{
FOR(dx, -1, 1)
{
FOR(dy, -1, 1)
{
FOR(k, 0, 3)
{
res.se += abs(f[i][j][k] - f[i + dx][j + dy][k]);
}
}
}
}
}
res.fi = SZ(s);
res.se /= (SZ(f) * SZ(f[0]));
return res;
}
ld dist(pdd a, pdd b)
{
return 0.0 * (a.fi - b.fi) * (a.fi - b.fi) + 4.0 * co * (a.se - b.se) * (a.se - b.se);
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500])
{
//calculate some quantity of
grid.resize(H);
FOR(i, 0, H)
{
grid[i].resize(W);
FOR(j, 0, W)
{
grid[i][j][0] = R[i][j];
grid[i][j][1] = G[i][j];
grid[i][j][2] = B[i][j];
}
}
ld dl = max(max(vals[0].fi, vals[1].fi), max(vals[2].fi, vals[3].fi)) - min(min(vals[0].fi, vals[1].fi), min(vals[2].fi, vals[3].fi));
ld dr = max(max(vals[0].se, vals[1].se), max(vals[2].se, vals[3].se)) - min(min(vals[0].se, vals[1].se), min(vals[2].se, vals[3].se));
co = (dl / dr) * (dl / dr);
auto cur = calc(grid);
ans = 0;
FOR(i, 1, 4)
{
if (dist(cur, vals[i]) < dist(cur, vals[ans]))
{
ans = i;
}
}
return ans + 1;
//calculate the minimum
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |