Submission #791812

# Submission time Handle Problem Language Result Execution time Memory
791812 2023-07-24T10:21:12 Z Dan4Life Land of the Rainbow Gold (APIO17_rainbow) C++17
11 / 100
14 ms 880 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a), end(a)
const int mxN = (int)55;
const int X[] = {1,-1,0,0};
const int Y[] = {0,0,1,-1};
int n, m;
bool a[mxN][mxN], vis[mxN][mxN];

void recur(int x, int y){
	if(x<0 or y<0 or x>=n or y>=m or a[x][y] or vis[x][y]) return;
	vis[x][y]=1; for(int i = 0; i < 4; i++) recur(x+X[i],y+Y[i]);
}

void init(int R, int C, int x, int y, int M, char *s) {
	x--, y--; a[x][y]=1; n = R, m = C;
	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++;
		a[x][y] = 1;
	}
}

int colour(int r1, int c1, int r2, int c2) {
	memset(vis,0,sizeof(vis));
	r1--,c1--,r2--,c2--; int cnt = 0;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < m; j++)
			if(i<r1 or i>r2 or j<c1 or j>c2) vis[i][j]=1;
	for(int i = r1; i <= r2; i++)
		for(int j = c1; j <= c2; j++)
			if(!vis[i][j] and !a[i][j]) 
				recur(i,j),cnt++;
	return cnt;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 14 ms 428 KB Output is correct
4 Correct 14 ms 340 KB Output is correct
5 Correct 7 ms 380 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 12 ms 340 KB Output is correct
12 Correct 11 ms 340 KB Output is correct
13 Correct 8 ms 340 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Runtime error 1 ms 468 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Runtime error 1 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 14 ms 428 KB Output is correct
4 Correct 14 ms 340 KB Output is correct
5 Correct 7 ms 380 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 12 ms 340 KB Output is correct
12 Correct 11 ms 340 KB Output is correct
13 Correct 8 ms 340 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Runtime error 9 ms 880 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 212 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 14 ms 428 KB Output is correct
4 Correct 14 ms 340 KB Output is correct
5 Correct 7 ms 380 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 12 ms 340 KB Output is correct
12 Correct 11 ms 340 KB Output is correct
13 Correct 8 ms 340 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 1 ms 304 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Runtime error 9 ms 880 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -