답안 #262478

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
262478 2020-08-13T01:18:04 Z daniel920712 무지개나라 (APIO17_rainbow) C++14
12 / 100
91 ms 7176 KB
#include "rainbow.h"
#include <queue>
#include <stdio.h>
#include <utility>
using namespace std;
int 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]={0};
int con2[200005]={0};
int con3[200005]={0};
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,j,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<=R;i++) 
	{
		
		for(j=1;j<=C;j++) printf("%d",all[i][j]);
		printf("\n");
	}*/
    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 'void init(int, int, int, int, int, char*)':
rainbow.cpp:17:11: warning: unused variable 'j' [-Wunused-variable]
   17 |     int i,j,now1=0,now2=0,now3=0;
      |           ^
rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:48:9: warning: unused variable 'ans' [-Wunused-variable]
   48 |     int ans=0,x,y,i,j,k;
      |         ^~~
rainbow.cpp:48:15: warning: unused variable 'x' [-Wunused-variable]
   48 |     int ans=0,x,y,i,j,k;
      |               ^
rainbow.cpp:48:17: warning: unused variable 'y' [-Wunused-variable]
   48 |     int ans=0,x,y,i,j,k;
      |                 ^
rainbow.cpp:48:19: warning: unused variable 'i' [-Wunused-variable]
   48 |     int ans=0,x,y,i,j,k;
      |                   ^
rainbow.cpp:48:21: warning: unused variable 'j' [-Wunused-variable]
   48 |     int ans=0,x,y,i,j,k;
      |                     ^
rainbow.cpp:48:23: warning: unused variable 'k' [-Wunused-variable]
   48 |     int ans=0,x,y,i,j,k;
      |                       ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 71 ms 6500 KB Output is correct
4 Correct 91 ms 7160 KB Output is correct
5 Correct 76 ms 7160 KB Output is correct
6 Correct 72 ms 6776 KB Output is correct
7 Correct 74 ms 6896 KB Output is correct
8 Correct 87 ms 6372 KB Output is correct
9 Correct 85 ms 7176 KB Output is correct
10 Correct 69 ms 7024 KB Output is correct
11 Correct 77 ms 6704 KB Output is correct
12 Correct 59 ms 6724 KB Output is correct
13 Correct 72 ms 7032 KB Output is correct
14 Correct 59 ms 7032 KB Output is correct
15 Correct 62 ms 6648 KB Output is correct
16 Correct 72 ms 6648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Runtime error 4 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -