# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
59624 | spencercompton | Art Class (IOI13_artclass) | C++17 | 177 ms | 6832 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;
class Color{
public:
int r, g, b;
Color(int x, int y, int z){
r = x;
g = y;
b = z;
}
bool operator<(const Color &o) const{
if(r!=o.r){
return r<o.r;
}
if(g!=o.g){
return g<o.g;
}
return b<o.b;
}
bool cool(Color o, int tol){
int val = (r-o.r)*(r-o.r) + (g-o.g) * (g-o.g) + (b-o.b) * (b-o.b);
// cout << "@ " << val << " " << tol << endl;
return val<=tol;
}
};
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
vector<Color> li;
double gsum = 0.0;
double asum = 0.0;
for(int i = 0; i<H; i++){
for(int j = 0; j<W; j++){
li.push_back(Color(R[i][j],G[i][j],B[i][j]));
if(G[i][j] >=R[i][j] && G[i][j]>=B[i][j]){
gsum++;
}
asum++;
}
}
double rat = gsum/asum;
int tol = 5000;
int cnt = 0;
sort(li.begin(),li.end());
for(int i = 0; i<li.size(); i++){
bool nex = true;
for(int j = max(0,i-500); j<i && nex; j++){
nex &= !li[i].cool(li[j],tol);
}
for(int j =0; nex && i>0 && j<400; j++){
int ind = rand()%i;
nex &= !li[i].cool(li[ind],tol);
}
if(nex){
cnt++;
}
}
if(rat>=0.70){
return 2;
}
if(cnt>=40){
return 1;
}
if(cnt<=6){
return 4;
}
return 3;
// cout << cnt << " " << rat << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |