# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
658015 | cristi_a | Art Class (IOI13_artclass) | C++17 | 64 ms | 3572 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;
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
int area = H * W;
int nonclr = 0;
int green = 0;
for(int i=0; i<H; i++)
for(int j=0; j<W; j++) {
int r = R[i][j], g = G[i][j], b = B[i][j];
if(abs(r-g) < 13 and abs(r-b) < 13 and abs(b-g) < 13) nonclr++;
if((g-r) + (g-b) >= 20 and g-r > -10 and g-b > -10) green++;
}
double non_color_percent = ((1.00 * nonclr) / (1.00 * area)) * 100.00;
double green_percent = (1.00 * green) / (1.00 * area) * 100.00;
static const double sigmaB = 30;
static const double sigmaN = 65;
static const int dx[] = {0, 0, -1, 1};
static const int dy[] = {1, -1, 0, 0};
auto in = [&](int a, int b) {
if(a < 0 or a >= H or b < 0 or b >= W) return false;
return true;
};
bool viz[500][500];
auto BFS = [&](double sigma) {
for(int i=0; i<H; i++)
for(int j=0; j<W; j++)
viz[i][j] = false;
queue<pair<int, int>> q;
int cnt = 0;
for(int i=0; i<H; i++)
for(int j=0; j<W; j++) {
if(viz[i][j]) continue;
cnt++;
q.emplace(i, j);
viz[i][j] = true;
while(q.empty() == false) {
int x, y; tie(x, y) = q.front(); q.pop();
for(int k=0; k<4; k++) {
int nx = x + dx[k];
int ny = y + dy[k];
if(!in(nx, ny) or viz[nx][ny]) continue;
/*int dif = abs(R[x][y] - R[nx][ny]) +
abs(G[x][y] - G[nx][ny]) +
abs(B[x][y] - B[nx][ny]);*/
int difr = abs(R[x][y] - R[nx][ny]);
int difg = abs(G[x][y] - G[nx][ny]);
int difb = abs(R[x][y] - R[nx][ny]);
double avg = 1.00 * (difr + difg + difb) / 3.00;
if(avg <= sigma) {
q.emplace(nx, ny);
viz[nx][ny] = true;
}
}
}
}
return cnt;
};
int blocks = BFS(sigmaB);
int nuances = BFS(sigmaN);
/*cout << "blocks: " << blocks << "\n";
cout << "nuances: " << nuances << "\n";
cout << "non_color: " << non_color_percent << "\n";
cout << "green: " << green_percent << "\n";
cout << "green: " << green << "\n";*/
if(blocks <= 180 and non_color_percent >= 30.00) return 1;
if(non_color_percent >= 55.00 and blocks <= 3000) return 1;
if(green_percent >= 35.00 and blocks <= 2500 and blocks >= 200) return 2;
if(nuances <= 60) return 4;
return 3;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |