Submission #262834

# Submission time Handle Problem Language Result Execution time Memory
262834 2020-08-13T09:43:32 Z srvlt Land of the Rainbow Gold (APIO17_rainbow) C++14
11 / 100
105 ms 4088 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include "rainbow.h"

const int n0 = 53;
int n, r, c, bad[n0][n0], used[n0][n0];
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};

void dfs(int x, int y) {
	if (x < 1 || x > r || y < 1 || y > c || bad[x][y] || used[x][y]) return;
	used[x][y] = 1;
	for (int i = 0; i < 4; i++)
		dfs(x + dx[i], y + dy[i]);
}

void init(int R, int C, int sr, int sc, int M, char *S) {
	r = R, c = C;
	int x = sr, y = sc;
	bad[x][y] = 1;
	for (int i = 0; i < M; i++) {
		if (S[i] == 'N') x--;
		if (S[i] == 'S') x++;
		if (S[i] == 'W') y--;
		if (S[i] == 'E') y++;
		bad[x][y] = 1;
	}
	
}

int colour(int ar, int ac, int br, int bc) {
	for (int i = 1; i <= r; i++)
		for (int j = 1; j <= c; j++)
			if (i < ar || i > br || j < ac || j > bc)
				bad[i][j]++;
	int res = 0;
	memset(& used, 0, sizeof(used));
	for (int i = 1; i <= r; i++)
		for (int j = 1; j <= c; j++)
			if (!used[i][j] && !bad[i][j])
				dfs(i, j), res++;
	for (int i = 1; i <= r; i++)
		for (int j = 1; j <= c; j++)
			if (i < ar || i > br || j < ac || j > bc)
				bad[i][j]--;
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 17 ms 384 KB Output is correct
3 Correct 27 ms 512 KB Output is correct
4 Correct 27 ms 384 KB Output is correct
5 Correct 16 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 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 27 ms 384 KB Output is correct
12 Correct 22 ms 384 KB Output is correct
13 Correct 19 ms 384 KB Output is correct
14 Correct 16 ms 384 KB Output is correct
15 Correct 0 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 Incorrect 105 ms 4088 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Runtime error 2 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 Correct 4 ms 384 KB Output is correct
2 Correct 17 ms 384 KB Output is correct
3 Correct 27 ms 512 KB Output is correct
4 Correct 27 ms 384 KB Output is correct
5 Correct 16 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 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 27 ms 384 KB Output is correct
12 Correct 22 ms 384 KB Output is correct
13 Correct 19 ms 384 KB Output is correct
14 Correct 16 ms 384 KB Output is correct
15 Correct 0 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 2 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 4 ms 384 KB Output is correct
2 Correct 17 ms 384 KB Output is correct
3 Correct 27 ms 512 KB Output is correct
4 Correct 27 ms 384 KB Output is correct
5 Correct 16 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 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 27 ms 384 KB Output is correct
12 Correct 22 ms 384 KB Output is correct
13 Correct 19 ms 384 KB Output is correct
14 Correct 16 ms 384 KB Output is correct
15 Correct 0 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 2 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Halted 0 ms 0 KB -