Submission #262860

# Submission time Handle Problem Language Result Execution time Memory
262860 2020-08-13T10:09:11 Z Saboon Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
3 ms 640 KB
#include <bits/stdc++.h>
#include "rainbow.h"
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;

map<char,int> adjr = {{'N', 1}, {'S', -1}};
map<char,int> adjc = {{'E', 1}, {'W', -1}};
int adjx[] = {0, -1};
int adjy[] = {-1, 0};
int R, C;
bool mark[51][51];
int par[52*52];

int get_par(int v){
	return par[v] < 0 ? v : par[v] = get_par(par[v]);
}

bool merge(int v, int u){
	if ((v = get_par(v)) == (u = get_par(u)))
		return false;
	if (par[v] > par[u])
		swap(v, u);
	par[u] = v;
	return true;
}

void init(int r, int c, int sr, int sc, int M, char* s){
	R = r, C = c;
	mark[sr][sc] = 1;
	for (int i = 0; i < M; i++){
		sr += adjr[s[i]], sc += adjc[s[i]];
		mark[sr][sc] = 1;
	}
}

int colour(int x1, int y1, int x2, int y2){
	int cnt = 0;
	memset(par, -1, sizeof par);
	for (int i = x1; i <= x2; i++){
		for (int j = y1; j <= y2; j++){
			if (mark[i][j])
				continue;
			cnt ++;
			if (i > x1 and !mark[i-1][j])
				merge((i-1)*C+j, (i-2)*C+j);
			if (j > y1 and !mark[i][j-1])
				merge((i-1)*C+j, (i-1)*C+j-1);
		}
	}
	return cnt;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -