#include "bits/stdc++.h"
#include "artclass.h"
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]){
array<int,3> tot = {0,0,0};
int last = -1, kac = 0, sb = 0;
for(int i=0;i<H;i++){
int r=0,g=0,b=0;
for(int j=0;j<W;j++){
tot[0] += R[i][j];
tot[1] += G[i][j];
tot[2] += B[i][j];
if(max({G[i][j],R[i][j],B[i][j]}) - min({G[i][j],R[i][j],B[i][j]}) <= 10) sb++;
if(G[i][j] >= (R[i][j]+B[i][j]) / 2) g++;
if(R[i][j] >= (G[i][j]+B[i][j]) / 2) r++;
if(B[i][j] >= (R[i][j]+G[i][j]) / 2) b++;
}
if(g >= (r+b) / 2){
kac += (last != 0);
last = 0;
}
else if(r >= (g+b) / 2){
kac += (last != 1);
last = 1;
}
else if(b >= (r+g) / 2){
kac += (last != 2);
last = 2;
}
else{
kac += (last != 3);
last = 3;
}
}
if(sb >= H*W/2) return 1;
if(tot[1] - (tot[0]+tot[2])/2 >= 10) return 2;
if(kac <= 3) return 4;
return 3;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |