Submission #57298

# Submission time Handle Problem Language Result Execution time Memory
57298 2018-07-14T14:03:00 Z thiago4532 Land of the Rainbow Gold (APIO17_rainbow) C++17
0 / 100
4 ms 680 KB
#include <bits/stdc++.h>
#include "rainbow.h"

using namespace std;
const int maxn = 2e5 + 10;
bool mat[3][maxn];
int n, m, pi, pj, rios[3][maxn];

void init(int R, int C, int sr, int sc, int M, char *S) {
	n = R, m = C;
	pi = sr, pj = sc;

	mat[sr][sc] = 1;	
	for(int i=0;i<M;i++){
		if(S[i] == 'N') --sr;
		else if(S[i] == 'S') ++sr;
		else if(S[i] == 'W') --sc;
		else if(S[i] == 'E') ++sc;

		mat[sr][sc] = 1;
	}

	for(int i=1;i<=2;i++){
		for(int j=1;j<=m;j++){
			rios[i][j] = rios[i][j-1];
			if(mat[i][j]){
				rios[i][j++]++;
				while(j <= m && mat[i][j]){
					rios[i][j] = rios[i][j-1];
					j++;
				}
			}
		}
	}
	for(int j=1;j<=m;j++){
		rios[0][j] = rios[0][j-1];
		if(mat[1][j] && mat[2][j]){
			rios[0][j++]++;
			while(j <= m && mat[1][j] && mat[2][j]){
				rios[0][j] = rios[0][j-1];
				j++;
			}
		}
	}
}

int colour(int ar, int ac, int br, int bc) {
	if(ar == br){
		return rios[ar][bc] - rios[ar][ac] + 1;
	}else{
		return rios[0][bc] - rios[0][ac] + 1;
	}
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 680 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -