# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
259845 | SamAnd | Art Class (IOI13_artclass) | C++17 | 101 ms | 6520 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;
#define m_p make_pair
const int N = 503;
const int xx[8] = {0, 1, 0, -1, 1, -1, 1, -1};
const int yy[8] = {1, 0, -1, 0, 1, -1, -1, 1};
double ans;
int n, m;
int r[N][N], g[N][N], b[N][N];
bool c[N][N];
void bfs(int x, int y, int qq, int d)
{
queue<pair<int, int> > q;
c[x][y] = true;
q.push(m_p(x, y));
while (!q.empty())
{
x = q.front().first;
y = q.front().second;
q.pop();
for (int i = 0; i < qq; ++i)
{
int hx = x + xx[i];
int hy = y + yy[i];
if (hx >= 0 && hx < n && hy >= 0 && hy < m && !c[hx][hy])
{
int u = 0;
u += abs(r[x][y] - r[hx][hy]);
u += abs(g[x][y] - g[hx][hy]);
u += abs(b[x][y] - b[hx][hy]);
if (u < d)
{
c[hx][hy] = true;
q.push(m_p(hx, hy));
}
}
}
}
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500])
{
n = H;
m = W;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
r[i][j] = R[i][j];
g[i][j] = G[i][j];
b[i][j] = B[i][j];
}
}
double t = 0;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
t += r[i][j];
t += g[i][j];
t += b[i][j];
}
}
t /= (n * m);
double gg = 0;
for (int i = 0; i < n - 1; ++i)
{
for (int j = 0; j < m - 1; ++j)
{
gg += abs(R[i][j] - R[i][j + 1]);
gg += abs(R[i][j] - R[i + 1][j]);
gg += abs(G[i][j] - G[i][j + 1]);
gg += abs(G[i][j] - G[i + 1][j]);
gg += abs(B[i][j] - B[i][j + 1]);
gg += abs(B[i][j] - B[i + 1][j]);
}
}
gg /= (n * m);
memset(c, false, sizeof c);
double q = 0;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < m; ++j)
{
if (!c[i][j])
{
q += 1;
bfs(i, j, 4, 50);
}
}
}
q /= (n * m);
q *= 10000;
//cout << t << endl;
if (q < 8)
return 4;
if (q > 1500)
return 3;
if (q < 100)
return 1;
if (t > 350)
return 1;
return 2;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |