RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 COCI00353

Čvenk

설명

Time limit: 3 seconds
Memory limit: 512 MB
Page \(1/2\)
A group of Czech tourists is walking in a labyrinth of a strange self-similar shape. The ground plan of
the labyrinth is a Sierpinski triangle – a fractal structure named after the Polish mathematician Wacław
Sierpiński.
The labyrinth consists of a billion rows numbered from 0 to \(10^{9} - 1\) from top to bottom, and a billion columns
numbered from 0 to \(10^{9} - 1\) from left to right. The fields in the labyrinth can be either free or blocked.
The field in row \(X\) and column \(Y\) is free if the result of the bitwise ‘and’ operation on the numbers \(X\) and
\(Y\) is equal to zero, otherwise it is blocked. In other words, a field is blocked if, when \(X\) and \(Y\) are switched
to binary, there is an integer \(k\) such that the \(k^{th}\) digit from the right of the number \(X\) and the \(k^{th}\) digit from
the right of the number \(Y\) are equal to 1.
The first 32 rows and columns \(of\) the labyrinth. The blocked fields are colored \(in\) black.
The Czech tourists are tired from a long day of wandering and would like to meet up in a free field and
exchange experiences. In each step, one tourist can jump to one of the adjacent free fields (up, down, left or
right).
Write a programme that will, based on the current tourists’ locations, determine minimum total number
of steps necessary in order for all the tourists to meet in the same field.
Time limit: 3 seconds
Memory limit: 512 MB
Page \(2/2\)

제약

subtask
subscore
constraints
1
17
\(N = 2\)
0 ⩽\(R_{K}\), \(S_{K} < 10^{9}\)
2
21
2 ⩽\(N\) ⩽100
0 ⩽\(R_{K}\), \(S_{K} < 10^{9}\)
3
22
2 ⩽\(N\)\(10^{5}\)
0 ⩽\(R_{K}\), \(S_{K} < 500\)
4
40
2 ⩽\(N\)\(10^{5}\)
0 ⩽\(R_{K}\), \(S_{K} < 10^{9}\)

입력 형식

The first line of input contains an integer \(N\) – the number of tourists. Each of the following \(N\) lines contains
two integers \(R_{i}\) and \(S_{i}\) – the row and column of the field where the \(i^{th}\) tourist is located.
All the tourists are located in free fields, and it is possible that there are multiple tourists in the same field.

출력 형식

The first and only line of output must contain the required minimum number of steps.
Please note: We recommend that you use a 64-bit integer data type (int64 in Pascal, long long in
\(C/C\)++).

예제 1
입력
2
2 1
4 3
6
2 5
3 4
8 7
9 6
10 5
11 4
출력
output
6
50
설명

Clarification of the first example: One of the fields where the brave Czech tourists could have met is
(2, 0).
Clarification of the second example: One of the fields where the playful Czech tourists could have met
is (8, 4).

문제 정보

생성자가 기록되지 않았습니다.

출처 COI 2015

평가 및 의견

Čvenk

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Čvenk

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8