#include <bits/stdc++.h>
#include "artclass.h"
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pi pair<int, int>
#define pl pair<ll,ll>
#define all(x) (x).begin(),(x).end()
bool is_green(array<int,3> a) {
return a[1]>=max(a[0],a[2])+3;
}
bool is_white(array<int,3> a) {
return (*min_element(all(a))>220);
}
bool diff(array<int,3> a, array<int,3> b) {
int d=0;
for (int i=0; i<3; i++) {
d+=abs(a[i]-b[i]);
}
return d>=7;
}
int style(int h, int w, int r[500][500], int g[500][500], int b[500][500]) {
int green=0,white;
int hor=0,ver=0;
for (int i=0; i<h; i++) {
for (int j=0; j<w; j++) {
green+=is_green({r[i][j],g[i][j],b[i][j]});
white+=is_white({r[i][j],g[i][j],b[i][j]});
if (i!=h-1) {
ver+=diff({r[i][j],g[i][j],b[i][j]},{r[i+1][j],g[i+1][j],b[i+1][j]});
}
if (j!=w-1) {
hor+=diff({r[i][j],g[i][j],b[i][j]},{r[i][j+1],g[i][j+1],b[i][j+1]});
}
}
}
if (white>h*w/10) {
return 1;
}
if (green>h*w/5) {
return 2;
}
if (hor<h*w/2) {
return 4;
}
return 3;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |