Hash Server

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

요약
알 수 없는 소수 매개변수 해시의 입출력 100쌍이 주어질 때 100개의 새 질의에 같은 해시 값을 계산해 답한다.
난이도

어려움10점 중 9점

유형
수학, 정수론, 완전 탐색, 구현
정답자
아직 제출이 없습니다

문제

This is an interactive, run-twice problem.

There is a hash server whose purpose is to hash strings of length 1010. However, it has a problem: it is about to stop working, as it can only handle 100100 more strings. Your task is to write a program that can replicate the server's behavior.

A string ss is hashed as follows. Let s_is\_i be the 11-based alphabetic number of the ii-th letter. The hash is calculated using the following formula:

∑_i=110(s_i⋅xk_i)⋅(a_i+s_i)(mod2610),\sum\_{i=1}^{10}(s\_i\cdot x^{k\_i})\cdot(a\_i + s\_i) \pmod {26^{10}},

where the parameters a_ia\_i, k_ik\_i (1≤i≤101 \leq i \leq 10), and xx (x>max⁡_i=110(max⁡(a_i,k_i))x > \max\limits\_{i=1}^{10}(\max(a\_i, k\_i))) are distinct prime numbers from 11 to 10910^9, set on the hash server. These parameters are unknown constants.

To generate a response, the hash server converts the number into a string of length 1010. It is written in the positional numeral system with base 2626, but every digit is represented by a letter: aa represents digit 00, bb represents digit 11, etc. If the resulting number is too short, leading zeroes are added to make it exactly 1010 digits long.

Your program will run twice. During the first run, your program can make at most 100100 unique requests to the server. For every request, the hash server returns the hash of the given string.

During the second run, your program will receive a list of server responses from the first run in an arbitrary order. Your program must then process 100100 hash requests from the jury's program and produce the same responses as the original server.

힌트

The example of the second run contains only 77 requests for brevity. In the testing system, the jury's program will make 100100 requests in the first test.

Here are the parameters that are used in the sample:

  • x=73x = 73.
  • a=(71,67,61,59,53,47,43,41,37,31)a = (71, 67, 61, 59, 53, 47, 43, 41, 37, 31).
  • k=(29,23,19,17,13,11,7,5,3,2)k = (29, 23, 19, 17, 13, 11, 7, 5, 3, 2).

예제2

  1. 예제 1

    입력
    1
    
    wilyevxwyy
    
    gcfffvmuie
    
    nykaeyifai
    
    omhdftcmgu
    
    wqjmrukrfi
    
    
    예상 출력
    
    aaaaaaaaaa
    
    bbbbbbbbbb
    
    ababababab
    
    bababababa
    
    aaaaabbbbb
    
    done
    
  2. 예제 2

    입력
    2
    5
    nykaeyifai
    omhdftcmgu
    gcfffvmuie
    wilyevxwyy
    wqjmrukrfi
    aaaaaaaaaa
    
    bbbbbbbbbb
    
    cccccccccc
    
    dddddddddd
    
    eeeeeeeeee
    
    ffffffffff
    
    gggggggggg
    
                    ...
    
    예상 출력
    
    
    
    
    
    
    
    
    wilyevxwyy
    
    gcfffvmuie
    
    dhfvcyssbs
    
    nxntwfpqfo
    
    lzdblqdots
    
    xlzrxeinse
    
    wkdrewenay
                    ...