Submission #262900

# Submission time Handle Problem Language Result Execution time Memory
262900 2020-08-13T10:42:40 Z Saboon Land of the Rainbow Gold (APIO17_rainbow) C++14
11 / 100
22 ms 896 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 R, C;
bool mark[52][52];
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])
				cnt -= merge((i-1)*C+j, (i-2)*C+j);
			if (j > y1 and !mark[i][j-1])
				cnt -= merge((i-1)*C+j, (i-1)*C+j-1);
		}
	}
	return cnt;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 22 ms 384 KB Output is correct
4 Correct 21 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 19 ms 384 KB Output is correct
12 Correct 13 ms 512 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 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 768 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 Correct 3 ms 512 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 22 ms 384 KB Output is correct
4 Correct 21 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 19 ms 384 KB Output is correct
12 Correct 13 ms 512 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Runtime error 3 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 22 ms 384 KB Output is correct
4 Correct 21 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 19 ms 384 KB Output is correct
12 Correct 13 ms 512 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Runtime error 3 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -