제출 #383618

#제출 시각아이디문제언어결과실행 시간메모리
383618alishahali1382미술 수업 (IOI13_artclass)C++14
47 / 100
102 ms8044 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;
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];
	}
	ld green=0, Sum=0;
	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) continue ;
		if (g/sum>.5) green++;
//		Sum+=sum;
	}
	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)<=50) comp-=join(i*m+j, (i+1)*m+j);
		if (j<m-1 && diff(i, j, i, j+1)<=50) comp-=join(i*m+j, i*m+(j+1));
	}
	ld S=0;
	for (int i=0; i<n; i++) for (int j=0; j+1<m; j++) S+=diff(i, j, i, j+1);
	S/=n*m;
	green/=n*m;
//	cerr<<"S: "<<setprecision(10)<<fixed<<S<<"\n";
//	debug(green)
	//debug(comp)
//	green/=Sum;
//	cerr<<"green: "<<setprecision(10)<<fixed<<green<<"\n";
	
	if (S>50) return 3;
	if (S<=8) return 4;
	return rng()%2+1;
}

컴파일 시 표준 에러 (stderr) 메시지

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:50:14: warning: unused variable 'Sum' [-Wunused-variable]
   50 |  ld green=0, Sum=0;
      |              ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...