# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076247 | TheQuantiX | Art Class (IOI13_artclass) | C++17 | 46 ms | 6236 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 <bits/stdc++.h>
#include "artclass.h"
using namespace std;
using ll = long long;
float dist(float a, float b, float c, float a1, float b1, float c1) {
a /= 255;
b /= 255;
c /= 255;
a1 /= 255;
b1 /= 255;
c1 /= 255;
return (abs(a - a1) + abs(b - b1) + abs(c - c1)) / 3.;
}
float zones(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
vector< vector<bool> > vis(H, vector<bool> (W));
float ans = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (vis[i][j]) {
continue;
}
ans++;
queue< pair<ll, ll> > q;
q.push({i, j});
vis[i][j] = 1;
while (!q.empty()) {
auto p = q.front();
q.pop();
if (p.first > 0 && !vis[p.first - 1][p.second] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first - 1][p.second], G[p.first - 1][p.second], B[p.first - 1][p.second]) < 0.2) {
q.push({p.first - 1, p.second});
vis[p.first - 1][p.second] = 1;
}
if (p.second > 0 && !vis[p.first][p.second - 1] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first][p.second - 1], G[p.first][p.second - 1], B[p.first][p.second - 1]) < 0.2) {
q.push({p.first, p.second - 1});
vis[p.first][p.second - 1] = 1;
}
if (p.first < H - 1 && !vis[p.first + 1][p.second] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first + 1][p.second], G[p.first + 1][p.second], B[p.first + 1][p.second]) < 0.2) {
q.push({p.first + 1, p.second});
vis[p.first + 1][p.second] = 1;
}
if (p.second < W - 1 && !vis[p.first][p.second + 1] && dist(R[p.first][p.second], G[p.first][p.second], B[p.first][p.second], R[p.first][p.second + 1], G[p.first][p.second + 1], B[p.first][p.second + 1]) < 0.2) {
q.push({p.first, p.second + 1});
vis[p.first][p.second + 1] = 1;
}
}
}
}
ans /= (H / 100.);
ans /= (W / 100.);
return ans;
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
mt19937 gen(chrono::system_clock::now().time_since_epoch().count());
auto f1 = zones(H, W, R, G, B);
if (f1 < 0.5) {
return 4;
}
else if (f1 < 31) {
return 2;
}
else if (f1 < 150) {
return 1;
}
else {
return 3;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |