Logo
(追記) (追記ここまで)

11164번 - Traveling Cellsperson 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB148544537.500%

문제

You have solved every problem from Project Euler in your head. Now it is time for a problem you might have heard of, namely The Traveling Salesperson, whose decision version is NP-complete. We consider the Traveling Salesperson problem in a 2D rectangular grid where every cell can be reached from their neighboring cells (up, down, left and right) and you can visit a cell as many times as you like (though, most of the cells aren’t that interesting, so you might prefer not to visit them a lot).

입력

The first line of the input consists of a single integer T, the number of test cases. Then follow two integers X and Y , marking the width and height of the grid, respectively. Then follow Y lines with X characters, where the character ’C’ is a cell and the character ’S’ is the starting point.

  • 0 < T ≤ 50
  • 0 < X ≤ 100
  • 0 < Y ≤ 100
  • All characters in a test case are ’C’, except for exactly one, which is ’S’.

출력

For each test case, output the minimum number of steps required to make a full roundtrip of the grid, starting and ending at S, and visiting each cell at least once.

Since you realize that this won’t lead anywhere, finish off the output with “LOL” (without quotes) on a line of its own (one per run, not per test case).

제한

예제 입력 1

1
4 4
CCCC
CCCC
CSCC
CCCC

예제 출력 1

16
LOL

힌트

출처

Contest > IDI Open Contest > IDI Open 2013 G번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /