Submission #111825

# Submission time Handle Problem Language Result Execution time Memory
111825 2019-05-16T10:00:23 Z dndhk Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
25 ms 768 KB
#include "rainbow.h"
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <iostream>

using namespace std;

const int MAX_N = 50;

typedef long long ll;
typedef pair<int, int> pii;

bool chk[MAX_N+1][MAX_N+1];
int R, C;

void init(int r, int c, int sr, int sc, int M, char *S) {
	R = r; C = c;
	chk[sc][sr] = true;
	for(int i=0; i<M; i++){
		if(S[i]=='N')	sr--;
		else if(S[i]=='E')	sc++;
		else if(S[i]=='W')	sc--;
		else sr++;
		//cout<<sr<<" "<<sc<<endl;
		chk[sr][sc] = true;
	}
}

bool vst[MAX_N+1][MAX_N+1];

pii A, B;

int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};

void dfs(int x, int y){
	if(x<A.first || x>B.first|| y<A.second || y>B.second)	return;
	if(vst[x][y] || chk[x][y])	return;
	vst[x][y] = true;
	for(int i=0; i<4; i++){
		dfs(x+dx[i], y+dy[i]);
	}
}

int colour(int ar, int ac, int br, int bc) {
	A = {ar, ac}; B = {br, bc};
	for(int i=ar; i<=br; i++){
		for(int j=ac; j<=bc; j++){
			vst[i][j] = false;
		}
	}
	int ans = 0;
	for(int i=ar; i<=br; i++){
		for(int j=ac; j<=bc; j++){
			if(!chk[i][j] && !vst[i][j]){
				//cout<<i<<" "<<j<<endl;
				ans++;
				dfs(i, j);
			}
		}
	}
    return ans;
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 15 ms 384 KB Output is correct
4 Correct 25 ms 384 KB Output is correct
5 Correct 15 ms 512 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 3 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Runtime error 3 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 5 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 15 ms 384 KB Output is correct
4 Correct 25 ms 384 KB Output is correct
5 Correct 15 ms 512 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 3 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 15 ms 384 KB Output is correct
4 Correct 25 ms 384 KB Output is correct
5 Correct 15 ms 512 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Incorrect 3 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -