# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123119 | Mahdi_Jfri | Art Class (IOI13_artclass) | C++14 | 264 ms | 20832 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;
#define ll long long
#define pb push_back
const int maxn = 5e2 + 20;
const int dx[] = {0 , 0 , -1 , 1};
const int dy[] = {1 ,-1 , 0 , 0};
struct node
{
int r , g , b;
node(int r_ = -1 , int g_ = -1 , int b_ = -1)
{
r = r_ , g = g_ , b = b_;
}
bool almostEqual(node c)
{
int x = max(abs(r - c.r) , max(abs(g - c.g) , abs(b - c.b)));
return x <= 40;
}
bool operator < (node c)
{
if(almostEqual(c))
return 0;
else
return r < c.r;
}
};
int style(int n , int m , int R[500][500] , int G[500][500] , int B[500][500])
{
vector<int> tmp1 , tmp2 , tmp3;
vector<node> val;
for(int x = 0; x < n; x++)
for(int y = 0; y < m; y++)
{
val.pb(node(R[x][y] , G[x][y] , B[x][y]));
for(int i = 0; i < 4; i++)
{
int nx = x + dx[i] , ny = y + dy[i];
if(0 <= nx && nx < n && 0 <= ny && ny < m)
{
tmp1.pb(abs(R[x][y] - R[nx][ny]));
tmp2.pb(abs(G[x][y] - G[nx][ny]));
tmp3.pb(abs(B[x][y] - B[nx][ny]));
}
}
}
sort(val.begin() , val.end());
int cnt = 0;
for(int i = 0; i < n * m; i++)
{
int j = i;
while(j + 1 < n * m && val[j].almostEqual(val[j + 1]))
j++;
i = j;
cnt++;
}
sort(tmp1.begin() , tmp1.end());
sort(tmp2.begin() , tmp2.end());
sort(tmp3.begin() , tmp3.end());
tmp1.erase(tmp1.begin() , tmp1.begin() + 5000);
tmp2.erase(tmp2.begin() , tmp2.begin() + 5000);
tmp3.erase(tmp3.begin() , tmp3.begin() + 5000);
int sz = tmp1.size();
int sum1 = tmp1[sz / 2] , sum2 = tmp2[sz / 2] , sum3 = tmp3[sz / 2];
vector<int> tmp = {sum1 , sum2 , sum3};
sort(tmp.begin() , tmp.end());
sum1 = tmp[1];
if(sum1 <= 10)
return 4;
if(sum1 >= 30)
return 3;
return 2;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |