oun7204   2년 전

문제를 푸는데, 이동에대한 로직이 잘못 되었는지 2번 케이스를 돌리면 20에서 완료가 됩니다.

문제를 넣고 돌리면 

처음에 현재 좌표와 방향을 먼저주고, 확인하기 위해 map을 출력해서 눈으로 확인후에 다음 진행할 방향과 다음 좌표를 queue 에다가 너어주면서 진행을 하고 있습니다.

이다음에 나오는 값들이 제 코드를  실행시키면 나오는 값들인데, 이대로 진행하면 20칸이 채워지고 나서 종료가 되는것이 맞는 답인거 같습니다ㅠㅠ

계속 이것만 보아서 어디가 틀렸는지 감이 안오는데 도와주세요...ㅠㅠ

pointX = 7 pointY =4 d =0 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1000201101

1000001101

1000000001

1111111111

nextX = 7 nextY =3 d =3

첫 if

pointX = 7 pointY =3 d =3 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002201101

1000001101

1000000001

1111111111

nextX = 8 nextY =3 d =2

첫 if

pointX = 8 pointY =3 d =2 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002201101

1002001101

1000000001

1111111111

nextX = 8 nextY =4 d =1

첫 if

pointX = 8 pointY =4 d =1 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002201101

1002201101

1000000001

1111111111

nextX = 7 nextY =4 d =0

첫 if

pointX = 8 pointY =4 d =0 check = 1

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002201101

1002201101

1000000001

1111111111

nextX = 8 nextY =3 d =3

첫 if

pointX = 8 pointY =4 d =3 check = 2

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002201101

1002201101

1000000001

1111111111

nextX = 9 nextY =4 d =2

첫 if

pointX = 9 pointY =4 d =2 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002201101

1002201101

1000200001

1111111111

nextX = 9 nextY =5 d =1

첫 if

pointX = 9 pointY =5 d =1 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002201101

1002201101

1000220001

1111111111

nextX = 8 nextY =5 d =0

첫 if

pointX = 8 pointY =5 d =0 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002201101

1002221101

1000220001

1111111111

nextX = 8 nextY =4 d =3

첫 if

pointX = 8 pointY =5 d =3 check = 1

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002201101

1002221101

1000220001

1111111111

nextX = 9 nextY =5 d =2

첫 if

pointX = 8 pointY =5 d =2 check = 2

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002201101

1002221101

1000220001

1111111111

nextX = 8 nextY =6 d =1

첫 if

pointX = 8 pointY =5 d =1 check = 3

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002201101

1002221101

1000220001

1111111111

nextX = 7 nextY =5 d =0

첫 if

pointX = 7 pointY =5 d =0 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002221101

1002221101

1000220001

1111111111

nextX = 7 nextY =4 d =3

첫 if

pointX = 7 pointY =5 d =3 check = 1

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002221101

1002221101

1000220001

1111111111

nextX = 8 nextY =5 d =2

첫 if

pointX = 7 pointY =5 d =2 check = 2

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002221101

1002221101

1000220001

1111111111

nextX = 7 nextY =6 d =1

첫 if

pointX = 7 pointY =5 d =1 check = 3

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000000101

1002221101

1002221101

1000220001

1111111111

nextX = 6 nextY =5 d =0

첫 if

pointX = 6 pointY =5 d =0 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000020101

1002221101

1002221101

1000220001

1111111111

nextX = 6 nextY =4 d =3

첫 if

pointX = 6 pointY =4 d =3 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000220101

1002221101

1002221101

1000220001

1111111111

nextX = 7 nextY =4 d =2

첫 if

pointX = 6 pointY =4 d =2 check = 1

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000220101

1002221101

1002221101

1000220001

1111111111

nextX = 6 nextY =5 d =1

첫 if

pointX = 6 pointY =4 d =1 check = 2

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000000001

1000220101

1002221101

1002221101

1000220001

1111111111

nextX = 5 nextY =4 d =0

첫 if

pointX = 5 pointY =4 d =0 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1000200001

1000220101

1002221101

1002221101

1000220001

1111111111

nextX = 5 nextY =3 d =3

첫 if

pointX = 5 pointY =3 d =3 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1000220101

1002221101

1002221101

1000220001

1111111111

nextX = 6 nextY =3 d =2

첫 if

pointX = 6 pointY =3 d =2 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1002220101

1002221101

1002221101

1000220001

1111111111

nextX = 6 nextY =4 d =1

첫 if

pointX = 6 pointY =3 d =1 check = 1

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1002220101

1002221101

1002221101

1000220001

1111111111

nextX = 5 nextY =3 d =0

첫 if

pointX = 6 pointY =3 d =0 check = 2

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1002220101

1002221101

1002221101

1000220001

1111111111

nextX = 6 nextY =2 d =3

첫 if

pointX = 6 pointY =2 d =3 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1002221101

1002221101

1000220001

1111111111

nextX = 7 nextY =2 d =2

첫 if

pointX = 7 pointY =2 d =2 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1022221101

1002221101

1000220001

1111111111

nextX = 7 nextY =3 d =1

첫 if

pointX = 7 pointY =2 d =1 check = 1

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1022221101

1002221101

1000220001

1111111111

nextX = 6 nextY =2 d =0

첫 if

pointX = 7 pointY =2 d =0 check = 2

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1022221101

1002221101

1000220001

1111111111

nextX = 7 nextY =1 d =3

첫 if

pointX = 7 pointY =1 d =3 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1222221101

1002221101

1000220001

1111111111

nextX = 8 nextY =1 d =2

첫 if

pointX = 8 pointY =1 d =2 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1222221101

1202221101

1000220001

1111111111

nextX = 8 nextY =2 d =1

첫 if

pointX = 8 pointY =2 d =1 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1222221101

1222221101

1000220001

1111111111

nextX = 7 nextY =2 d =0

첫 if

pointX = 8 pointY =2 d =0 check = 1

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1222221101

1222221101

1000220001

1111111111

nextX = 8 nextY =1 d =3

첫 if

pointX = 8 pointY =2 d =3 check = 2

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1222221101

1222221101

1000220001

1111111111

nextX = 9 nextY =2 d =2

첫 if

pointX = 9 pointY =2 d =2 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1222221101

1222221101

1020220001

1111111111

nextX = 9 nextY =3 d =1

첫 if

pointX = 9 pointY =3 d =1 check = 0

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1222221101

1222221101

1022220001

1111111111

nextX = 8 nextY =3 d =0

첫 if

pointX = 9 pointY =3 d =0 check = 1

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1222221101

1222221101

1022220001

1111111111

nextX = 9 nextY =2 d =3

첫 if

pointX = 9 pointY =3 d =3 check = 2

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1222221101

1222221101

1022220001

1111111111

nextX = 10 nextY =3 d =2

첫 if

pointX = 9 pointY =3 d =2 check = 3

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1222221101

1222221101

1022220001

1111111111

nextX = 9 nextY =4 d =1

첫 if

pointX = 9 pointY =3 d =1 check = 4

=================

1111111111

1000000001

1000111101

1001100001

1011000001

1002200001

1022220101

1222221101

1222221101

1022220001

1111111111

nextX = 8 nextY =3 d =0

첫 if

20

eric00513   2년 전

지금 데이터 입력하신 것을 보면, N=11, M=10인 데이터만 테스트하셨습니다. 제 Java 컴파일러가 이상해서 실행은 못해보되, N=M=1인 데이터나 최대나 최소 데이터를 넣어 보세요.

djm03178   2년 전

예전에 이와 같은 질문에 대한 답을 한 적이 있는 것 같은데... 질문이 지워졌나 봅니다.

청소는 다음과 같이 진행됩니다.

eric00513   2년 전

https://www.acmicpc.net/board/...

에 엄청 많은 글들이 있으니, 참고하시기 바랍니다.

oun7204   2년 전

감사합니다~~ 우선 진행 방향에 관해 잘못 된것같네요 ㅠㅠ 

oun7204   2년 전

드디어 성공했습니다~~~

저의 문제는 while문에 들어가면 무조건 방향을 일단 바꿔주고 시작을 하였는데,

뒤로가는 상황에서는 원래 방향으로 접근을 해야 했는데, 그 부분을 빠뜨리고 진행해서 생긴 문제 였습니다..

도와주신 모든 분들 감사합니다~

수정한 코드도 첨부합니다.

댓글을 작성하려면 로그인해야 합니다.