Submission #29682

#TimeUsernameProblemLanguageResultExecution timeMemory
29682dereotuArt Class (IOI13_artclass)C++14
0 / 100
112 ms3684 KiB
#include "artclass.h"
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define forr(i,A,B) for(int i=A;i<B;++i)
#define space ' '
#define endl '\n'
#define LL long long
using namespace std;

int vis[500][500];
int cntx;
int dr[]={1,0,0,-1};
int dl[]={0,1,-1,0};
int green,cnt,advcnt,hello;
int g[500][500],r[500][500],b[500][500];
int h,w;
void type2(int xx,int yy){
	queue<pair<int,int> > q;
	q.push(mp(xx,yy));
	while(!q.empty()){
		int x=q.front().st;
		int y=q.front().nd;
		q.pop();
		if(vis[x][y]) continue;
		if(g[x][y]-r[x][y]>5 and g[x][y]-b[x][y]>5) green++;
		vis[x][y]=1;
		forr(i,0,4){
			int nx=x+dr[i];
			int ny=y+dl[i];
			if(nx>=0 and nx<h and ny>=0 and ny<w and !vis[x+dr[i]][y+dl[i]]){
				q.push(mp(nx,ny));
			}
		}
	}
}


void keko(int xx,int yy){
	queue<pair<int,int> > q;
	q.push(mp(xx,yy));
	while(!q.empty()){
		int x=q.front().st;
		int y=q.front().nd;
		q.pop();
		if(vis[x][y]) continue;
		if(g[x][y]-r[x][y]>20 and g[x][y]-b[x][y]>20) green++;
		vis[x][y]=1;
		forr(i,0,4){
			int nx=x+dr[i];
			int ny=y+dl[i];
			if(nx>=0 and nx<h and ny>=0 and ny<w and !vis[x+dr[i]][y+dl[i]]){
				if(g[x+dr[i]][y+dl[i]]<=50 and r[x+dr[i]][y+dl[i]]<=50 and b[x+dr[i]][y+dl[i]]<=50) continue;
					q.push(mp(nx,ny));
			}
		}
	}
}


void advancedflood(int xx,int yy){
	queue<pair<int,int> > q;
	q.push(mp(xx,yy));
	while(!q.empty()){
		int x=q.front().st;
		int y=q.front().nd;
		q.pop();
		if(vis[x][y]) continue;
		if(g[x][y]-r[x][y]>20 and g[x][y]-b[x][y]>20) green++;
		vis[x][y]=1;
		forr(i,0,4){
			int nx=x+dr[i];
			int ny=y+dl[i];
			if(nx>=0 and nx<h and ny>=0 and ny<w and !vis[x+dr[i]][y+dl[i]]){
				if(g[x][y]-g[x+dr[i]][y+dl[i]]>=50 or r[x][y]-r[x+dr[i]][y+dl[i]]>=50 or b[x][y]-b[x+dr[i]][y+dl[i]]>=50) continue;
					q.push(mp(nx,ny));
			}
		}
	}
}


int style(int H, int W, int R[500][500], int G[500][500], int B[500][500]) {
	return 1;
	forr(i,0,500) forr(j,0,500){
		r[i][j]=R[i][j];
		b[i][j]=B[i][j];
		g[i][j]=G[i][j];
	}
	w=W-1;
	h=H-1;
	type2(0,0);
	if(green>=H*W*0.6) return 2;
	forr(i,0,500){
		forr(j,0,500){
			if(!vis[i][j]){
				++cnt;
				keko(i,j);
			}
		}
	}
	memset(vis,0,sizeof vis);
	forr(i,0,500){
		forr(j,0,500){
			if(!vis[i][j]){
				++advcnt;
				advancedflood(i,j);
			}
		}
	}
	if(cnt>=15) return 1;
	if(advcnt<=5) return 4;
	else return 3;

}
#Verdict Execution timeMemoryGrader output
Fetching results...