Dice Encryption Algorithm

시간 제한3초메모리 제한2048 MB

요약
10^100 이하의 수를 18500번의 주사위 굴림 과정으로 선택해 암호화하고, 기록을 이용해 원래 수를 복호화하는 인터랙티브 문제다.
난이도

어려움10점 중 8점

유형
확률, 수학, 구현
정답자
아직 제출이 없습니다

문제

This is an interactive run-twice problem.

What is a game without a little gambling? But wait... we're serious people here, and gambling is not for us! Instead, let's dive into the world of encryption algorithms. However, to keep things intriguing, we will introduce a new encryption algorithm that uses randomness derived from rolling dice!

You will be given a number xx ranging from 00 to 1010010^{100}. Your task is to encrypt this number through a series of dice rolls and then decrypt it to return to the original value.

The encryption process consists of exactly 18,50018\\,500 steps. At each step, you will be given three six-faced dice. The dice are fair: all faces have an equal probability of being selected. Each face of each die displays an integer from 00 to 99 selected uniformly at random, independently of the others. You will then select one of the three given dice. After that, the jury will roll your chosen die once, and record the outcome.

힌트

The example contains only 1010 steps. This is only to demonstrate the format of input and output. During system testing, there will be exactly 18,50018\\,500 steps.

예제2

  1. 예제 1

    입력
    1
    1
    2 1 8 2 5 9 2 8 2 6 2 9 9 0 3 8 5 7
    
    2
    0 9 7 2 9 3 2 5 5 2 0 6 8 8 8 4 9 4
    
    6
    0 9 9 9 7 7 0 7 6 6 6 0 4 6 9 2 5 3
    
    3
    4 2 9 2 1 2 2 7 0 5 3 5 5 0 5 8 3 1
    
    9
    3 0 7 7 6 7 0 4 8 1 2 5 0 0 9 1 2 9
    
    0
    4 9 3 1 5 7 9 3 7 5 9 2 6 9 2 6 9 5
    
    6
    7 4 3 6 5 2 3 0 2 2 5 8 3 5 0 7 7 4
    
    3
    2 2 0 2 4 3 3 0 8 4 4 7 6 9 8 3 6 2
    
    8
    5 3 9 9 3 3 1 4 0 5 2 4 1 8 6 6 4 3
    
    4
    3 2 4 6 0 2 5 8 8 1 4 8 3 9 1 5 6 6
    
    8
    
    예상 출력
    
    
    
    1
    
    
    2
    
    
    3
    
    
    1
    
    
    2
    
    
    3
    
    
    1
    
    
    2
    
    
    3
    
    
    2
    
    
  2. 예제 2

    입력
    2
    2639063848
    
    
    예상 출력
    
    
    1