# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
805106 | ma_moutahid | Art Class (IOI13_artclass) | C++17 | 66 ms | 12060 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>
using ll =long long;
ll LINF=1000000000000000000;
int INF=1000000000;
#define pi pair<int,int>
#define pl pair<ll,ll>
#define endl '\n'
#define vi vector<int>
#define vii vector<vector<int>>
#define vl vector<ll>
#define vll vector<vector<ll>>
//#define int ll
using namespace std;
#include "artclass.h"
int margin;
int w,h;
vii g(500,vi(500)),b(500,vi(500)),r(500,vi(500));
int color=0;
vii id(500,vi(500));
bool compare_color(int i,int j,int x, int y){
int R=r[i][j]-r[x][y];
int B=b[i][j]-b[x][y];
int G=g[i][j]-b[x][y];
int diff=B*B+G*G+R*R;
return diff<=margin*margin;
}
vii checked(500,vi(500));
void countcolor(int x,int y){
if(checked[x][y])return;
checked[x][y]=1;
if(id[x][y]==0){
color++;
id[x][y]=color;
}
if(y+1<h){
bool same= compare_color(x,y,x,y+1);
if(same){
id[x][y+1]=id[x][y];
}
countcolor(x,y+1);
}
if(x+1<w){
bool same= compare_color(x,y,x+1,y);
if(same){
id[x+1][y]=id[x][y];
}
countcolor(x+1,y);
}
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
for(int i=0;i<500;i++)for(int j=0;j<500;j++)g[i][j]=G[i][j],b[i][j]=B[i][j],r[i][j]=R[i][j];
h=H;
w=W;
int colors;
int COLORS;
//test 1: strict number of colors
margin =2;
countcolor(0,0);
COLORS=color;
//test 2: not so strict number of colors
margin =6;
id=vii(500,vi(500));
countcolor(0,0);
colors=color;
//test 3 : how green
int sum=0;
for(int i=0;i<W;i++)for(int j=0;j<H;j++)sum+=G[i][j];
sum/=h*H;
int result=0;
if(COLORS/colors<3){
return 1;
}
if(colors<6)return 4;
if(sum>150)return 2;
return 3;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |