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

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

Two Missing Numbers

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

요약
숫자 스트림을 두 번의 실행에 나눠 받아, 두 번씩 나타나는 값들 사이에서 정확히 한 번만 나타나는 두 값을 찾아낸다.
난이도

보통10점 중 7점

유형
비트 연산, 구현, 수학, 해시맵
정답자
아직 제출이 없습니다

문제

This is a run-twice problem: your solution will be executed twice on each test. See the rest of the statement and the input format section for more details.

You are a given a stream of integers such that each integer in the stream appears exactly twice, except for exactly two integers both of which appear exactly once. Your task is to construct a streaming algorithm that finds these two integers.

입력

Your solution will be invoked on each test twice.

On each invocation, the first line contains two integers qq and nn (q∈1,2q \in \\{1, 2\\}, 0≤n≤1060 \leq n \leq 10^6): the number of invocation and the size of the part of the stream. Additionally, on the second invocation, the first line also contains two integers xx and yy: the output of your program after the first invocation in the same exact order.

The second line contains nn 64-bit unsigned integers separated by a space: the part of the stream itself.

In the first and the second parts combined, out of the integers that appear at all, each integer appears exactly twice, except for exactly two integers both of which appear exactly once.

출력

Your program has to print two 64-bit unsigned integers. The numbers after the first invocation will be given to your program on the second invocation in the same exact order. The numbers after the second invocation should be the answer (order is not important).

예제2

  1. 예제 1

    입력
    1 5
    5 1 4 4 5
    
    예상 출력
    1 736
    
  2. 예제 2

    입력
    2 3 1 736
    9 9 3
    
    예상 출력
    1 3