# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
16032 | ainu7 | Art Class (IOI13_artclass) | C++98 | 0 ms | 0 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 <algorithm>
#include <vector>
#include "artclass.h"
using namespace std;
const double PI = 3.141592653589793238;
void avestd(int H, int W, int R[500][500], int G[500][500], int B[500][500], int step, double res[6]) {
int cnt = 0;
double r_sum = 0, g_sum = 0, b_sum = 0;
double r_sq = 0, g_sq = 0, b_sq = 0;
for ( int i = step; i<H; i+=step )
for ( int j = step; j<W; j+=step) {
cnt += 2;
int rr = R[i][j] - R[i][j-step];
int gg = G[i][j] - G[i][j-step];
int bb = B[i][j] - B[i][j-step];
r_sum += abs(rr);
g_sum += abs(gg);
b_sum += abs(bb);
r_sq += rr*rr;
g_sq += gg*gg;
b_sq += bb*bb;
rr = R[ i ][ j ] - R[ i - step ][ j ];
gg = G[ i ][ j ] - G[ i - step ][ j ];
bb = B[ i ][ j ] - B[ i - step ][ j ];
r_sum += abs(rr);
g_sum += abs(gg);
b_sum += abs(bb);
r_sq += rr*rr;
g_sq += gg*gg;
b_sq += bb*bb;
}
res[0] = r_sum / cnt;
res[1] = g_sum / cnt;
res[2] = b_sum / cnt;
res[3] = sqrt(( r_sq - ( r_sum / cnt )*r_sum ) / cnt);
res[4] = sqrt(( g_sq - ( g_sum / cnt)*g_sum ) / cnt);
res[5] = sqrt(( b_sq - ( b_sum / cnt )*b_sum ) / cnt);
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500])
{
double P[100][6];
avestd(H, W, R, G, B, 1, P[ 1 ]);
avestd(H, W, R, G, B, 3, P[ 3 ]);
avestd(H, W, R, G, B, 10, P[ 10 ]);
// printf("%f %f %f %f %f %f\n", P[ 1 ][ 0 ], P[ 1 ][ 1 ], P[ 1 ][ 2 ], P[ 1 ][ 3 ], P[ 1 ][ 4 ], P[ 1 ][ 5 ]);
// printf("%f %f %f %f %f %f\n", P[ 3 ][ 0 ], P[ 3 ][ 1 ], P[ 3 ][ 2 ], P[ 3 ][ 3 ], P[ 3 ][ 4 ], P[ 3 ][ 5 ]);
// printf("%f %f %f %f %f %f\n", P[ 10 ][ 0 ], P[ 10 ][ 1 ], P[ 10 ][ 2 ], P[ 10 ][ 3 ], P[ 10 ][ 4 ], P[ 10 ][ 5 ]);
if (P[10][0] + P[10][1] + P[10][2] < 40 && P[10][3] + P[10][4] + P[10][5] < 80) return 4;
double dd = P[10][0] / P[1][0] + P[10][1] / P[1][1] + P[10][2] / P[1][2];
if (dd > 9) return 1;
if (P[10][0] + P[10][1] + P[10][2] > 110) return 3;
return 2;
}