# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
59635 | spencercompton | Art Class (IOI13_artclass) | C++17 | 1147 ms | 35968 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:
double r, g, b;
Color(){
r = 0;
g = 0;
b = 0;
}
Color(int x, int y, int z){
double tot = x+y+z;
r = x;
r/= tot;
g = y;
g/= tot;
b = z;
b /= tot;
}
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, double tol){
double 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;
// cout << "J " << endl;
vector<Color> cc[H];
// cout << "G " << endl;
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]));
cc[i].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++;
}
}
// cout << "F" << endl;
double rat = gsum/asum;
// int tol = 5000;
// double tol = 0.00003;
double tol = 0.00005;
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-100); j<i && nex; j++){
nex &= !li[i].cool(li[j],tol);
}
for(int j =0; nex && i>0 && j<100; j++){
int ind = rand()%i;
nex &= !li[i].cool(li[ind],tol);
}
if(nex){
cnt++;
}
}
// cout << cnt << " " << rat << endl;
int cnt2 = 0;
bool v[H][W];
for(int i = 0; i<H; i++){
for(int j = 0; j<W; j++){
v[i][j] = false;
}
}
vector<int> dx;
vector<int> dy;
for(int i = -10; i<=10; i++){
for(int j = -10; j<=10; j++){
if(abs(i)+abs(j)>=4){
continue;
}
dy.push_back(i);
dx.push_back(j);
}
}
vector<int> all;
int mini = 4000;
for(int i = 0; i<H; i++){
for(int j = 0; j<W; j++){
if(v[i][j]){
continue;
}
cnt2++;
vector<pair<int, int> > q;
v[i][j] = true;
q.push_back(make_pair(i,j));
for(int k = 0; k<q.size(); k++){
for(int a = 0; a<dy.size(); a++){
int ny = q[k].first + dy[a];
int nx = q[k].second + dx[a];
if(ny>=0 && ny<H && nx>=0 && nx<W && !v[ny][nx] && cc[q[k].first][q[k].second].cool(cc[ny][nx],tol)){
v[ny][nx] = true;
q.push_back(make_pair(ny,nx));
}
}
}
if(q.size()<=1000){
cnt2--;
}
// cout <<
all.push_back(q.size());
}
}
sort(all.begin(),all.end());
// for(int i = 0; i<all.size(); i++){
// cout << all[i] << endl;
// }
// cout << "! " << cnt2 << endl;
double prop = (double)all[all.size()-1] / (double)(H*W);
double prop2 = 0.0;
for(int i = 1; i<=4 && i<=all.size(); i++){
prop2 += all[all.size()-i];
}
prop2 /= (double)(H*W);
// cout << "Z" << all[all.size()-1] << endl;
// cout << "@ " << prop << " " << prop2 << endl;
if(rat<0.5){
return 2;
}
assert(false);
// if(prop2>=0.80){
// return 4;
// }
// else if(prop2 <=0.15){
// return 1;
// }
// else if(prop2>=0.45){
// return 3;
// }
return 2;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |