Submission #489219

# Submission time Handle Problem Language Result Execution time Memory
489219 2021-11-21T16:21:20 Z cfalas Art Class (IOI13_artclass) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
//#include "artclass.h"
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
#define F first
#define S second

int getR(int RGB) { return (RGB >> 16) & 0xFF; }

int getG(int RGB) { return (RGB >> 8) & 0xFF; }

int getB(int RGB) { return RGB & 0xFF; }

int style(int h, int w, int r[500][500], int g[500][500], int b[500][500]) {
	int blackcount=0;
	int wcount=0;
	int gcount=0;
	double stdb,stdr,stdg;
	double totb=0,totg=0,totr=0;
	double sfrr=0,sfgg=0,sfbb=0;
	double pix = h*w;
	double dev=0;
	double devv=0, dcnt=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(r[i][j]+b[i][j]+g[i][j]<=25) blackcount++;
			else if(r[i][j]+b[i][j]+g[i][j]>=675) wcount++;
			if(g[i][j]>=100 && r[i][j]+b[i][j]<=150) gcount++;
			totb+=b[i][j];
			sfbb+=b[i][j]*b[i][j];
			totr+=r[i][j];
			sfrr+=r[i][j]*r[i][j];
			if(i!=0) dev+=abs(r[i][j]-r[i-1][j]), dcnt++, devv+=(r[i][j]-r[i-1][j])*(r[i][j]-r[i-1][j]);
			if(j!=0) dev+=abs(r[i][j]-r[i][j-1]), dcnt++, devv+=(r[i][j]-r[i][j-1])*(r[i][j]-r[i][j-1]);
			if(i!=h-1) dev+=abs(r[i][j]-r[i+1][j]), dcnt++, devv+=(r[i][j]-r[i+1][j])*(r[i][j]-r[i+1][j]);
			if(j!=w-1) dev+=abs(r[i][j]-r[i][j+1]), dcnt++, devv+=(r[i][j]-r[i][j+1])*(r[i][j]-r[i][j+1]);
		}
	}
	stdb = sqrt(sfbb/pix - (totb/pix)*(totb/pix));
	stdr = sqrt(sfrr/pix - (totr/pix)*(totr/pix));

	double devstd = sqrt(devv/dcnt - (dev/dcnt)*(dev/dcnt));
	//cout<<gcount/((double)h*w)<<endl;
	//if(wcount!=0) cout<<(double)blackcount/wcount<<endl;
	//cout<<devstd<<endl;
	if(devstd<6) return 4;
	if(devstd>23) return 3;
	if(gcount>0.02*h*w) return 2;
	if(wcount>0.03*((double)h*w) || blackcount>0.01*(h*w)) return 1;// ||(wcount!=0 && (double)blackcount/wcount<300)) return 1;
	if(devstd>17.5) return 3;
	return 2;
}

/*
int main(){
	int t;
	cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		int r[500][500];
		int g[500][500];
		int b[500][500];
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++){
				int a;
				cin>>a;
				r[i][j] = getR(a);
				g[i][j] = getG(a);
				b[i][j] = getB(a);
			}
		}
		cout<<style(n,m,r,g,b)<<endl;
	}
}
*/

Compilation message

artclass.cpp: In function 'int style(int, int, int (*)[500], int (*)[500], int (*)[500])':
artclass.cpp:19:9: warning: variable 'stdb' set but not used [-Wunused-but-set-variable]
   19 |  double stdb,stdr,stdg;
      |         ^~~~
artclass.cpp:19:14: warning: variable 'stdr' set but not used [-Wunused-but-set-variable]
   19 |  double stdb,stdr,stdg;
      |              ^~~~
artclass.cpp:19:19: warning: unused variable 'stdg' [-Wunused-variable]
   19 |  double stdb,stdr,stdg;
      |                   ^~~~
artclass.cpp:20:16: warning: unused variable 'totg' [-Wunused-variable]
   20 |  double totb=0,totg=0,totr=0;
      |                ^~~~
artclass.cpp:21:16: warning: unused variable 'sfgg' [-Wunused-variable]
   21 |  double sfrr=0,sfgg=0,sfbb=0;
      |                ^~~~
/usr/bin/ld: /tmp/ccPWIvml.o: in function `main':
grader.c:(.text.startup+0x200): undefined reference to `style'
collect2: error: ld returned 1 exit status