# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
383599 | alishahali1382 | Art Class (IOI13_artclass) | C++14 | 79 ms | 22764 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>
#pragma GCC optimize ("O2,unroll-loops")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;
const int inf=1000000010;
const ll INF=1000000000000001000LL;
const int mod=1000000007;
const int MAXN=500, LOG=20;
int n, m, k, u, v, x, y, t, a, b, comp, green;
int mark[MAXN][MAXN];
int R[MAXN][MAXN], G[MAXN][MAXN], B[MAXN][MAXN];
int dx[]={0, +1, 0, -1};
int dy[]={-1, 0, +1, 0};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void dfs(int x, int y){
if (x<0 || x>=n || y<0 || y>=m || mark[x][y]) debug("FUCK dfs")
mark[x][y]++;
for (int i=0; i<4; i++){
int xx=x+dx[i], yy=y+dy[i];
if (0<=xx && xx<n && 0<=yy && yy<m && !mark[xx][yy]){
int diff=abs(R[x][y]-R[xx][yy])+abs(G[x][y]-G[xx][yy])+abs(B[x][y]-B[xx][yy]);
if (diff<=50) dfs(xx, yy);
}
}
}
int style(int nn, int mm, int RR[500][500], int GG[500][500], int BB[500][500]) {
// cerr<<"FUCK YOU\n";
n=nn;
m=mm;
for (int i=0; i<n; i++) for (int j=0; j<m; j++){
R[i][j]=RR[i][j];
G[i][j]=GG[i][j];
B[i][j]=BB[i][j];
}
for (int i=0; i<n; i++) for (int j=0; j<m; j++){
ld r=R[i][j], g=G[i][j], b=B[i][j], sum=r+g+b;
if (sum!=0 && g/sum>.4) green++;
}
for (int i=0; i<n; i++) for (int j=0; j<m; j++) if (!mark[i][j]){
//cerr<<"FUCK YOU 2\n";
dfs(i, j);
//debug2(i, j)
comp++;
}
//debug(green)
//debug(comp)
if (comp<=6) return 4;
if (comp<=25) return 1;
if (green>=n*m/4) return 2;
return 3;
}
/*
int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>m;
for (int i=0; i<n; i++) for (int j=0; j<m; j++) cin>>R[i][j]>>G[i][j]>>B[i][j];
cout<<"ans: "<<style(n, m, R, G, B)<<"\n";
return 0;
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |