#include<bits/stdc++.h>
#include "artclass.h"
using namespace std;
#define ll long long
const ll MAX_diff = 25;
const ll bsf_interation = 50;
const vector<pair<ll, ll>> bsf_direction = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
srand(98485232);
auto Cal_diff = [&](pair<ll, ll> a, pair<ll, ll> b){
return abs(R[a.first][a.second] - R[b.first][b.second]) +
abs(G[a.first][a.second] - G[b.first][b.second]) +
abs(B[a.first][a.second] - B[b.first][b.second]);
};
vector<vector<ll>> bsf_check(H, vector<ll>(W, -1));
ll sum_bsf = 0;
for(ll i = 0; i < bsf_interation; i++){
queue<pair<ll, ll>> bsf_q;
pair<ll, ll> FirstPostion = {rand() % H, rand() % W};
bsf_q.emplace(FirstPostion);
bsf_check[FirstPostion.first][FirstPostion.second] = i;
sum_bsf++;
while(!bsf_q.empty()){
pair<ll, ll> position = bsf_q.front();
bsf_q.pop();
for(pair<ll, ll> dir : bsf_direction){
pair<ll, ll> NextPosition = {position.first + dir.first, position.second + dir.second};
if(NextPosition.first < 0 || NextPosition.first >= H ||
NextPosition.second < 0 || NextPosition.second >= W){
break;
}
else if(bsf_check[NextPosition.first][NextPosition.second] == i){
break;
}
else if(Cal_diff(NextPosition, FirstPostion) > MAX_diff){
break;
}
bsf_q.emplace(NextPosition);
bsf_check[NextPosition.first][NextPosition.second] = i;
sum_bsf++;
}
}
}
ll avg_bsf = sum_bsf/bsf_interation;
//cout << "avg_bsf = " << avg_bsf << endl;
if(avg_bsf < 5){
return 3;
}
else if(avg_bsf < 50){
return 2;
}
else if(avg_bsf < 150){
return 1;
}
else{
return 4;
}
}