Submission #262472

# Submission time Handle Problem Language Result Execution time Memory
262472 2020-08-13T01:08:54 Z daniel920712 Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
3 ms 640 KB
#include "rainbow.h"
#include <queue>
#include <utility>
using namespace std;
bool all[55][200005]={0};
bool have[55][200005]={0};
int dx[5]={1,0,-1,0};
int dy[5]={0,-1,0,1};
int con1[200005];
int con2[200005];
int con3[200005];
queue < pair < int , int > > BFS;
void init(int R, int C, int sr, int sc, int M, char *S)
{
    all[sr][sc]=1;
    int i,now1=0,now2=0,now3=0;
    for(i=0;i<M;i++)
    {
        if(S[i]=='N') sr--;
        if(S[i]=='S') sr++;
        if(S[i]=='E') sc++;
        if(S[i]=='W') sc--;
        all[sr][sc]=1;
    }
    for(i=1;i<=C;i++)
    {
    	if((all[2][i]==0||all[1][i]==0)&&(i==1||(all[2][i-1]==1&&all[1][i-1]==1))) con3[i]=now3++;
		else con3[i]=con3[i-1];
		
		if((all[1][i]==0)&&(i==1||(all[1][i-1]==1))) con1[i]=now1++;
		else con1[i]=con1[i-1];
		
		if((all[2][i]==0)&&(i==1||(all[2][i-1]==1))) con2[i]=now2++;
		else con2[i]=con2[i-1];
	}

}

int colour(int ar, int ac, int br, int bc)
{
    int ans=0,x,y,i,j,k;
    if(ar==1&&br==1) return con1[bc]-con1[ac]+(all[1][ac]==0);
	if(ar==2&&br==2) return con2[bc]-con2[ac]+(all[2][ac]==0);
	return con3[bc]-con3[ac]+((all[1][ac]==0||all[2][ac]==0));
}

Compilation message

rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:41:9: warning: unused variable 'ans' [-Wunused-variable]
   41 |     int ans=0,x,y,i,j,k;
      |         ^~~
rainbow.cpp:41:15: warning: unused variable 'x' [-Wunused-variable]
   41 |     int ans=0,x,y,i,j,k;
      |               ^
rainbow.cpp:41:17: warning: unused variable 'y' [-Wunused-variable]
   41 |     int ans=0,x,y,i,j,k;
      |                 ^
rainbow.cpp:41:19: warning: unused variable 'i' [-Wunused-variable]
   41 |     int ans=0,x,y,i,j,k;
      |                   ^
rainbow.cpp:41:21: warning: unused variable 'j' [-Wunused-variable]
   41 |     int ans=0,x,y,i,j,k;
      |                     ^
rainbow.cpp:41:23: warning: unused variable 'k' [-Wunused-variable]
   41 |     int ans=0,x,y,i,j,k;
      |                       ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Runtime error 3 ms 640 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 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -