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

Pairs

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

ZAGREB – CROATIA
AUGUST 15 – 22

COMPETITION DAY 2 – PAIRS

PAIRS
Mirko and Slavko are playing with toy animals. First, they choose one of three boards given in the figure below.
Each board consists of cells (shown as circles in the figure) arranged into a one, two or three dimensional grid.

Board 1
Board 2
Board 3
Mirko then places N little toy animals into the cells.
The distance between two cells is the smallest number of moves that an animal would need in order to reach
one cell from the other. In one move, the animal may step into one of the adjacent cells (connected by line
segments in the figure).
Two animals can hear each other if the distance between their cells is at most D. Slavko's task is to calculate
how many pairs of animals there are such that one animal can hear the other.
TASK
Write a program that, given the board type, the locations of all animals, and the number D, finds the desired
number of pairs.

EXAMPLES

제약
입력 형식

The first line of input contains four integers in this order:

The board type B (1 ≤ B ≤ 3);

The number of animals N (1 ≤ N ≤ 100 000);

The largest distance D at which two animals can hear each other (1 ≤ D ≤ 100 000 000);

The size of the board M (the largest coordinate allowed to appear in the input):

When B=1, M will be at most 75 000 000.

When B=2, M will be at most 75 000.

When B=3, M will be at most 75.
Each of the following N lines contains B integers separated by single spaces, the coordinates of one toy animal.
Each coordinate will be between 1 and M (inclusive).
More than one animal may occupy the same cell.

1 6 5 100
25
50
50
10
20
23

2 5 4 10
5 2
7 2
8 4
6 5
4 4

3 8 10 20
10 10 10
10 10 20
10 20 10
10 20 20
20 10 10
20 10 20
20 20 10
20 20 20

출력 형식

Output should consist of a single integer, the number of pairs of animals that can hear each other.
Note: use a 64-bit integer type to calculate and output the result (long long in C/C++, int64 in Pascal).

ZAGREB – CROATIA
AUGUST 15 – 22

COMPETITION DAY 2 – PAIRS

GRADING
In test cases worth a total of 30 points, the number of animals N will be at most 1 000.
Furthermore, for each of the three board types, a solution that correctly solves all test cases of that type will be
awarded at least 30 points.

4

8

12

Clarification for the leftmost example. Suppose the animals are numbered 1 through 6 in the order in which
they are given. The four pairs are:

1-5 (distance 5)

1-6 (distance 2)

2-3 (distance 0)

5-6 (distance 3)
Clarification for the middle example. The eight pairs are:

1-2 (distance 2)

1-4 (distance 4)

1-5 (distance 3)

2-3 (distance 3)

2-4 (distance 4)

3-4 (distance 3)

3-5 (distance 4)

4-5 (distance 3)

문제 정보

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

출처 IOI 2007

평가 및 의견

Pairs

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

Log in to rate problems.

개별 의견

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

풀이 제출

Pairs

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