Deep Abyss

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

요약
128비트 비트 연산으로 이루어진 해시 함수 h가 절차로 주어질 때 h(x)=x인 최소 고정점 x를 찾거나 없으면 :( 를 출력한다.
난이도

어려움10점 중 10점

유형
비트 연산, 구현, 완전 탐색, 시뮬레이션
정답자
아직 제출이 없습니다

문제

Kieray has a hash function h(x)h(x). She wants you to help her find a fixed point x_0x\_0 of hh, such that h(x_0)=x_0h(x\_0) = x\_0.

입력

The input contains the description of h(x)h(x).

The function h(x)h(x) is described by a procedure in Frog language. In this language, variables (for example, xx, yy, zz) are 128-bit unsigned integers. At the beginning, the variable xx contains the input value to hh, and the other variables are all initialized to zeroes. The result of h(x)h(x) is the value of variable xx after the execution of the procedure.

The procedure contains at most 500 lines. Each line is an assignment that stores the result of an expression into a variable. Frog language supports bitwise negation (~), and (&), or (|), xor (^), and left/right shifting (<</>>). The semantics of these operations are similar to those in C/C++.

Each assignment contains at most one binary operation. (Hexa)decimal constant numbers are allowed in expressions. The bitwise negation (~) can be applied to each variable or constant at most once. Every expression except bitwise xor expression (^) contains at most one variable. The shift amount (right operand) of a shifting operation is non-negative and not greater than 128.

Here is the extended BNF specification of the Frog language:

Note: "*" means the preceding token appears zero or more times, and "{1,4}" means the preceding token appears one to four times. The symbol "␣" represents a single space character.

출력

Print the fixed point of h(x)h(x) in hexadecimal without leading zeroes, conforming to the format of Hexadecimal in the extended BNF specification. If there are multiple fixed points, print the minimum one. If there is no fixed point, print ":(" (without quotes) instead.

힌트

This is an illustration from Kieray. It's lovely.

예제4

  1. 예제 1

    입력
    x = x | 0x19260817
    
    예상 출력
    0x19260817
    
  2. 예제 2

    입력
    x = x ^ 0xdeadbeef
    
    예상 출력
    :(
    
  3. 예제 3

    입력
    y = ~x << 3
    z = ~x >> 2
    w = x & ~0xa
    k = ~x ^ 0xc
    k = k << 1
    k = k >> 2
    x = y ^ z
    p = k ^ w
    x = x ^ p
    
    예상 출력
    0x9a83dcd41ee6a0f73507b9a83dcd41ef
    
  4. 예제 4

    입력
    x = x | 0x1
    x = x << 128
    
    예상 출력
    0x0