# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
779694 | Sohsoh84 | Art Class (IOI13_artclass) | C++17 | 58 ms | 12052 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;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef long double ld;
#define X first
#define Y second
#define sep ' '
#define debug(x) cerr << #x << ": " << x << endl;
const ll MAXN = 500;
const ld GRTRFACTOR = 0.6;
const ld difflim = 300;
int n, m, A[MAXN][MAXN][3];
vector<pll> adj[MAXN][MAXN];
inline ld dist(int a, int b, int x, int y) {
ld ans = 0;
for (int i = 0; i < 3; i++)
ans += pow(abs(A[a][b][i] - A[x][y][i]), 1);
return ans;
}
inline int wow() {
int ans = 0;
for (int i = 0; i < n / 20; i++) {
for (int j = 0; j < m / 20; j++) {
bool flag = true;
for (int a = 0; a < 20; a++) {
for (int b = 0; b < 20; b++) {
if (dist(i, j, i + a, j + b) > difflim)
flag = false;
}
}
ans += flag;
}
}
return ans;
}
int lim;
double test = 0.5;
inline int horz_khat() {
int fans = 0;
for (int i = lim; i < n; i++) {
int ans = 0;
for (int j = 0; j < m; j++)
if (dist(i, j, i - lim, j) > difflim)
ans++;
if (ans > test * m) fans++;
}
return fans;
}
inline int vert_khat() {
int fans = 0;
for (int i = lim; i < m; i++) {
int ans = 0;
for (int j = 0; j < n; j++)
if (dist(j, i, j, i - lim) > difflim)
ans++;
if (ans > test * n) fans++;
}
return fans;
}
inline ld green_sum() {
ld s = 0, ts = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
s = s + A[i][j][1], ts = ts + A[i][j][0] + A[i][j][2];
s /= ts;
return s;
}
inline ld deltax() {
ld delta = 0;
for (int i = 1; i < n; i++) {
for (int j = 1; j < m; j++) {
ll x = 0;
for (int k = 0; k < 3; k++) {
x += A[i][j][k] - A[i - 1][j][k];
}
delta += x * x;
}
}
delta /= ld(n * m) * (n * m) / 1000.0;
return delta;
}
inline ld deltay() {
ld delta = 0;
for (int i = 1; i < n; i++) {
for (int j = 1; j < m; j++) {
ll x = 0;
for (int k = 0; k < 3; k++) {
x += A[i][j][k] - A[i][j - 1][k];
}
delta += x * x;
}
}
delta /= ld(n * m) * (n * m) / 1000.0;
return delta;
}
int style(int H_, int W_, int R_[500][500], int G_[500][500], int B_[500][500]) {
n = H_;
m = W_;
lim = (n + m) / 10;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
A[i][j][0] = R_[i][j], A[i][j][1] = G_[i][j], A[i][j][2] = B_[i][j];
if (deltax() + deltay() > 60) return 3;
if (deltax() + deltay() < 7) return 4;
if ((vert_khat() == 0 || horz_khat() == 0) && green_sum() > 0.5) return 2;
return 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |