아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Going in Circles

시간 제한2초메모리 제한1024 MB

요약
조명 스위치를 켜고 끌 수 있는 순환 열차에서 인접한 칸으로 이동하는 것만 가능할 때, 3n+500 이하의 동작으로 칸 수 n(3 ≤ n ≤ 5000)을 알아낸다.
난이도

보통10점 중 4점

유형
시뮬레이션, 구현
정답자
아직 제출이 없습니다

문제

Hercule Poirot, world-renowned detective, was having a lovely cup of tea in his compartment on the Disorient Express when the train conductor rushed in. "We have lost track of the number of train carriages," exclaimed the conductor. You see, this was no ordinary train, and had no first or last train carriage. Instead, the train carriages were connected to form a large cycle, causing the conductor's confusion.

Hercule thought for a moment. "That is most peculiar," he said. "But I may be able to help you." He reached over and grabbed the lamp from the side table. "You see, each train carriage has a light switch like this one. By moving between the carriages and toggling these switches, we can determine the number of train carriages."

The conductor was sceptical, but agreed to try it. "We are in a hurry," he said, "so please determine nn, the number of carriages that the train consists of, in at most 3n+5003n+500 steps." Here a step counts as either moving to an adjacent carriage or toggling a light switch in the current carriage. "The only thing I am certain of is that nn is at least 33 and at most 50005000."

예제1

  1. 예제 1

    입력
    0
    
    1
    
    1
    
    0
    
    1
    
    1
    
    1
    
    1
    
    
    예상 출력
    
    ? right
    
    ? right
    
    ? right
    
    ? flip
    
    ? left
    
    ? left
    
    ? left
    
    ! 3