# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170755 | AlexLuchianov | Art Class (IOI13_artclass) | C++14 | 78 ms | 6132 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 <iostream>
#include <fstream>
#include <iomanip>
#include <set>
using ll = long long;
using ld = long double;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
bool isgreen(int red, int green, int blue){
return red + 20 <= green && blue + 20 <= green ;
}
bool isred(int red, int green, int blue){
return 150 <= red && 50 <= green && 50 <= blue;
}
bool isblue(int red, int green, int blue){
return 50 <= red && 50 <= green && 150 <= blue;
}
int const whitethreshold = 530;
bool iswhite(int red, int green, int blue){
return whitethreshold <= red + green + blue;
}
int const nmax = 500;
int black[1 + nmax][1 + nmax];
int up[1 + nmax];
int biggestrectangle(int n, int m){
int result = 0;
for(int j = 0; j < m; j++)
up[j] = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++){
if(black[i][j] == 1)
up[j]++;
else
up[j] = 0;
}
for(int j = 0; j < m; j++) {
int smin = up[j];
for(int j2 = j; j2 < m; j2++) {
smin = MIN(smin, up[j2]);
result = MAX(result, smin * (j2 - j + 1));
}
}
}
return result;
}
int white[1 + nmax][1 + nmax];
int biggestrectanglewhite(int n, int m){
int result = 0;
for(int j = 0; j < m; j++)
up[j] = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++){
if(white[i][j] == 1)
up[j]++;
else
up[j] = 0;
}
for(int j = 0; j < m; j++) {
int smin = up[j];
for(int j2 = j; j2 < m; j2++) {
smin = MIN(smin, up[j2]);
result = MAX(result, smin * (j2 - j + 1));
}
}
}
return result;
}
std::set<int> used;
int style(int n, int m, int R[nmax][nmax], int G[nmax][nmax], int B[nmax][nmax]) {
return 1;
std::ofstream out ("artclass.txt");
ld totalgreen = 0, totaltotal = 0;
//out << n << " " << m << '\n';
used.clear();
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++) {
black[i][j] = (0 == iswhite(R[i][j], G[i][j], B[i][j]));
white[i][j] = iswhite(R[i][j], G[i][j], B[i][j]);
used.insert((R[i][j]<<16) |
(G[i][j]<<8) |
(B[i][j]) );
}
/*
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++)
if(isgreen(R[i][j], G[i][j], B[i][j]) == 1)
out << " ";
else
out << "#";
out << '\n';
}
*/
//*
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++) {
totalgreen += isgreen(R[i][j], G[i][j], B[i][j]);
}
//*/
/*
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++)
if(iswhite(R[i][j], G[i][j], B[i][j]))
out << " ";
else
out << "#";
out << '\n';
}
*/
ld blackpercent = ((double)biggestrectangle(n, m)) / (n * m);
ld whitepercent = ((double)biggestrectanglewhite(n, m)) / (n * m);
//std::cout << "Black rectangle: " << blackpercent << '\n';
ld greenpercent = ((double)totalgreen) / (n * m);
ld distribution = ((double)used.size()) / (n * m);
//*
std::cout << "Green: " << std::setprecision(6) << std::fixed << greenpercent << '\n';
std::cout << "White rectangle: " << whitepercent << '\n';
std::cout << "Distribution: " << distribution << '\n';
//*/
int points[5] = {0};
//points[2] = 1;
if(0.7 <= blackpercent)
points[4] += 10;
else if(0.3 <= blackpercent)
points[4] += 5;
else if(blackpercent <= 0.03)
points[3] += 7;
if(0.2 <= greenpercent)
points[2] += 7;
if(0.01 <= greenpercent)
points[2] += 4;
else if(greenpercent <= 0.00001)
points[2] -= 5;
if(0.05 <= greenpercent)
points[4] -= 5;
if(0.1 <= whitepercent)
points[1] += 3;
if(0.005 <= whitepercent)
points[3] -= 5;
if(0.32 <= distribution)
points[2] += 2;
int smax = 0;
for(int i = 1;i <= 4; i++)
smax = MAX(smax, points[i]);
//std::cout << smax << '\n';
for(int i = 1;i <= 4; i++)
if(smax == points[i])
return i;
return 2;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |