Submission #73481

# Submission time Handle Problem Language Result Execution time Memory
73481 2018-08-28T10:11:49 Z FedericoS Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
4 ms 640 KB
#include <iostream>
#include <queue>
#include <set>
#include "rainbow.h"
using namespace std;

bool B[3][100005];
bool V[3][100005];
int R,C;
int rmov[]={1,-1,0,0};
int cmov[]={0,0,1,-1};
queue<pair<int,int>> Q;
set<pair<int,int>> S[3];
int A[3][100005];
int P[3][2][100005];

void init(int R_, int C_, int sr, int sc, int M, char *W) {

	R=R_;
	C=C_;

	B[1][0]=B[2][0]=true;
	B[1][C+1]=B[2][C+1]=false;
	B[1][C+2]=B[2][C+2]=true;
	A[0][0]=A[1][0]=A[2][0]=-1;

	B[sr][sc]=true;
	int cont=0;

	for(int i=0;i<M;i++){

		if(W[i]=='S')
			sr++;
		if(W[i]=='N')
			sr--;
		if(W[i]=='E')
			sc++;
		if(W[i]=='W')
			sc--;

		B[sr][sc]=true;
	}

	for(int r=1;r<R+1;r++)
		for(int i=1;i<C+3;i++)
			if(B[r][i] and !B[r][i-1])
				A[r-1][i]=-1;
			else if(!B[r][i] and B[r][i-1])
				A[r-1][i]=++cont;
			else
				A[r-1][i]=A[r-1][i-1];

	for(int i=1;i<C+3;i++)
		if((B[2][i]&B[1][i]) and !(B[2][i-1]&B[1][i-1]))
			A[2][i]=-1;
		else if(!(B[2][i]&B[1][i]) and (B[2][i-1]&B[1][i-1]))
			A[2][i]=++cont;
		else
			A[2][i]=A[2][i-1];

	for(int k=0;k<3;k++){
		for(int i=1;i<C+3;i++)
			P[k][0][i]=A[k][i]==-1?P[k][0][i-1]:A[k][i];
		for(int i=C+1;i>=0;i--)
			P[k][1][i]=A[k][i]==-1?P[k][1][i+1]:A[k][i];
	}


	/*for(int k=0;k<3;k++){
		for(int i=0;i<C+2;i++)
			cout<<A[k][i]<<" ";
		cout<<endl;
	}

	for(int k=0;k<3;k++){
		for(int i=0;i<C+2;i++)
			cout<<P[k][0][i]<<" ";
		cout<<endl;
	}

	for(int k=0;k<3;k++){
		for(int i=0;i<C+2;i++)
			cout<<P[k][1][i]<<" ";
		cout<<endl;
	}/*

	/*for(int k=0;k<3;k++){
		for(auto p:S[k])
			cout<<p.first<<","<<p.second<<" ";
		cout<<endl;
	}*/

}

int colour(int ar, int ac, int br, int bc) {

	int k;

	if(ar==0 and br==0)
		k=0;
	if(ar==1 and br==1)
		k=1;
	if(ar==0 and br==1)
		k=2;

	return P[k][0][bc]-P[k][1][ac]+1;

}

Compilation message

rainbow.cpp:85:3: warning: "/*" within comment [-Wcomment]
  }/*
    
rainbow.cpp:87:2: warning: "/*" within comment [-Wcomment]
  /*for(int k=0;k<3;k++){
# 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 3 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 640 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 -