제출 #383604

#제출 시각아이디문제언어결과실행 시간메모리
383604alishahali1382Art Class (IOI13_artclass)C++14
67 / 100
101 ms7296 KiB
#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;

int n, m, k, u, v, x, y, t, a, b, ted, comp, green;
int par[MAXN*MAXN];
int R[500][500], G[500][500], B[500][500];
int dx[]={0, +1, 0, -1};
int dy[]={-1, 0, +1, 0};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int diff(int x, int y, int xx, int yy){
	return abs(R[x][y]-R[xx][yy])+abs(G[x][y]-G[xx][yy])+abs(B[x][y]-B[xx][yy]);
}
int getpar(int x){ return (par[x]==x?x:par[x]=getpar(par[x]));}
int join(int x, int y){
	x=getpar(x);
	y=getpar(y);
	par[x]=y;
	return (x!=y);
}

int style(int nn, int mm, int RR[500][500], int GG[500][500], int BB[500][500]) {
	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++;
	}
	iota(par, par+n*m, 0);
	comp=n*m;
	for (int i=0; i<n; i++) for (int j=0; j<m; j++){
		if (i<n-1 && diff(i, j, i+1, j)<=100) comp-=join(i*m+j, (i+1)*m+j);
		if (j<m-1 && diff(i, j, i, j+1)<=100) comp-=join(i*m+j, i*m+(j+1));
	}
	
	debug(green)
	debug(comp)
	
	if (comp<=6) return 4;
	if (comp<=25) return 1;
	if (green>=n*m/4) return 2;
	return 3;
}
#Verdict Execution timeMemoryGrader output
Fetching results...