# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962236 | NValchanov | Art Class (IOI13_artclass) | C++17 | 67 ms | 8424 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>
#include "artclass.h"
using namespace std;
typedef long long ll;
const ll MAXN = 512;
int a[MAXN][MAXN][3];
ll get_noise(ll i1, ll j1, ll i2, ll j2)
{
ll noiseR = abs(a[i1][j1][0] - a[i2][j2][0]);
ll noiseG = abs(a[i1][j1][1] - a[i2][j2][1]);
ll noiseB = abs(a[i1][j1][2] - a[i2][j2][2]);
return noiseR + noiseG + noiseB;
}
int style(int n, int m, int R[500][500], int G[500][500], int B[500][500])
{
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
a[i][j][0] = R[i][j];
a[i][j][1] = G[i][j];
a[i][j][2] = B[i][j];
}
}
ll noise_sum = 0;
for(int i = 0; i < n; i++)
{
for(int j = 0 ; j < m; j++)
{
if(i != 0)
noise_sum += get_noise(i, j, i - 1, j);
if(j != 0)
noise_sum += get_noise(i, j, i, j - 1);
if(i != 0 && j != 0)
noise_sum += get_noise(i, j, i - 1, j - 1);
}
}
ll average_noise = noise_sum / (n * m);
if(average_noise <= 36)
return 4;
else if(average_noise <= 78)
return 1;
else if(average_noise <= 192)
return 2;
else
return 3;
}
/**
int main()
{
freopen("style-4-2.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int n,m;
cin >> n >> m;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
cin >> r[i][j] >> g[i][j] >> b[i][j];
}
}
cout << style(n,m,r,g,b) << endl;
return 0;
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |