Submission #885859

#TimeUsernameProblemLanguageResultExecution timeMemory
885859MilosMilutinovicLand of the Rainbow Gold (APIO17_rainbow)C++14
11 / 100
3 ms960 KiB
#include "rainbow.h"
#include<bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int mat[55][55],lx,ly,rx,ry;

void init(int r,int c,int sc,int sr,int m,char* s){
	mat[sc][sr]=1;
	lx=rx=sc;
	ly=ry=sr;
	for(int i=0;i<m;i++){
		if(s[i]=='N') sc--;
		if(s[i]=='S') sc++;
		if(s[i]=='E') sr++;
		if(s[i]=='W') sr--;
		mat[sc][sr]=1;
		lx=min(lx,sc);
		rx=max(rx,sc);
		ly=min(ly,sr);
		ry=max(ry,sr);
	}
}

int colour(int x1,int y1,int x2,int y2){
	int res=0;
	if(x1<lx&&rx<x2&&y1<ly&&ry<y2) res=1;
	for(int i=x1;i<=x2;i++) for(int j=y1;j<=y2;j++) res+=1-mat[i][j];
	for(int i=x1;i<=x2;i++) for(int j=y1;j<=y2;j++){
		if(mat[i][j]==1) continue;
		if(i+1<=x2&&mat[i+1][j]==0) res--;
		if(j+1<=y2&&mat[i][j+1]==0) res--;
		if(i+1<=x2&&j+1<=y2&&mat[i+1][j]==0&&mat[i][j+1]==0&&mat[i+1][j+1]==0) res++;
	}
	return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...