# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
575812 | Belgutei | Art Class (IOI13_artclass) | C++17 | 57 ms | 3256 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>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second
using namespace std;
bool inbound(pair<int, int> now, int H, int W) {
if (now.ff < 0 || now.ff >= H) return 0;
if (now.ss < 0 || now.ss >= W) return 0;
return 1;
}
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
pair<int, int> dir[4] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
long long avr = 0, avg = 0, avb = 0, avdisp = 0, now, cnt, total = 0;
for (int i = 0; i < H; i++)
for (int j = 0; j < W; j++) {
avr += R[i][j];
avg += G[i][j];
avb += B[i][j];
now = 0, cnt = 0;
for (int k = 0; k < 4; k++) {
if (!inbound({i+dir[k].ff, j+dir[k].ss}, H, W))
continue;
cnt++;
now += abs(R[i][j]-R[i+dir[k].ff][j+dir[k].ss]);
now += abs(G[i][j]-G[i+dir[k].ff][j+dir[k].ss]);
now += abs(B[i][j]-B[i+dir[k].ff][j+dir[k].ss]);
}
if (cnt) {
now /= cnt*3;
if (now > 40)
avdisp++;
}
}
if (avdisp)
avdisp = H*W/avdisp;
avr /= (H*W);
avg /= (H*W);
avb /= (H*W);
// cout << avr << ' ' << avg << ' ' << avb << ' ' << avdisp << '\n';
if (avdisp < 40 && avdisp >= 5)
return 1;
if (avdisp < 5)
return 3;
if (avdisp > 500)
return 4;
if (abs(avg-avb)+abs(avr-avb) > 50)
return 2;
return 1;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |