Submission #791798

# Submission time Handle Problem Language Result Execution time Memory
791798 2023-07-24T10:10:53 Z Dan4Life Land of the Rainbow Gold (APIO17_rainbow) C++17
0 / 100
3000 ms 7360 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)5e2+10;
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 = 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 Incorrect 8 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 568 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Execution timed out 3056 ms 7360 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Runtime error 1 ms 708 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -