프로그램 명: usa_chkr
제한시간: 1 초

[문제요약] 한 번에 게임을 끝내기 위한 최적의 방법(최소 이동)을 찾는 문제.

체커 게임

- + - + - + - +  K 는 베시의 왕: o 는 적
+ - + - + - + -  
- + - K - + - +  왕들은 연속적으로 적들의 checker 를 대각선 방향으로  넘을 수 있다.
+ - + - + - + -  넘김을 당한 적의 checker 는 죽는다.
- o - o - + - +
+ - K - + - + -  이 보드판의 답은 8 행 3 렬의 왕이 연속적으로 움직여 게임을 끝낼 수 있다.
- o - + - + - +  그림에서 움직이는 왕은 >K< 표시   
+ - K - + - K -  
아래와 그림이 주어질 때 그림과 같이 움직이면 끝.

입력의 데이터는 유일한 방법이 존재하거나 아니면 존재하지 않는다. 존재하지 않으면 impossible 을 출력


The cows have taken up the game of checkers with a vengeance. Unfortunately, despite their infinite enjoyment of playing, they are terrible at the endgame. They want your help.

Given an NxN (4 <= N <= 30) checkboard, determine the optimal set of moves to end the game on the next move. Checkers move only on the '+' squares and capture by jumping 'over' an opponent's piece. The piece is removed as soon as it is jumped. See the example below where N=8:

- + - + - + - +  The K's mark Bessie's kings; the o's represent the
+ - + - + - + -  opponent's checkers. Bessie always moves next. The
- + - K - + - +  Kings jump opponent's checkers successively in any
+ - + - + - + -  diagonal direction (and removes pieces when jumped).
- o - o - + - +
+ - K - + - + -  For this board, the solution requires the lower left
- o - + - + - +  King to jump successively across all three of the
+ - K - + - K -  opponents' checkers, thus ending the game (moving K
                 marked as >K<):

   Original          After move 1       After move 2        After move 3
- + - + - + - +     - + - + - + - +    - + - + - + - +     - + - + - + - +
+ - + - + - + -     + - + - + - + -    + - + - + - + -     + - + - + - + -
- + - K - + - +     - + - K - + - +    - + - K - + - +     - + - K - + - +
+ - + - + - + -     + - + - + - + -    + ->K<- + - + -     + - + - + - + -
- o - o - + - +     - o - o - + - +    - + - o - + - +     - + - + - + - +
+ - K - + - + -    >K<- K - + - + -    + - K - + - + -     + - K ->K<- + -
- o - + - + - +     - + - + - + - +    - + - + - + - +     - + - + - + - +
+ ->K<- + - K -     + - + - + - K -    + - K - + - K -     + - K - + - K -

The moves traversed these squares:

  1 2 3 4 5 6 7 8           R C
1 - + - + - + - +    start: 8 3
2 + - + - + - + -    move:  6 1
3 - + - K - + - +    move:  4 3
4 + - * - + - + -    move:  6 5
5 - o - o - + - +
6 * - K - * - + - 
7 - o - + - + - + 
8 + - K - + - K - 
Write a program to determine the (unique, as it turns out) game-ending sequence for an NxN input board if it exists. There is at least a king and at least one opponent piece on the board.

입력

출력

* Lines 1..?: If this sequence of moves is impossible, output "impossible" on a line by itself. If such a sequence exist, each line contains two space-separated integers that represent successive locations of a king whose moves will win the game.

입출력 예

입력

8
-+-+-+-+
+-+-+-+-
-+-K-+-+
+-+-+-+-
-o-o-+-+
+-K-+-+-
-o-+-+-+
+-K-+-K-

출력

8 3
6 1
4 3
6 5
출처:usaco 2008 DEC bronze

[질/답] [제출 현황] [푼 후(0)]
[ 채 점 ] [홈으로]  [뒤 로]