Logo
(追記) (追記ここまで)

25728번 - Connecting Cables 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)137736150.413%

문제

Recently, RUN was asked to connect cables between all pairs of the $N$ areas of KAIST.

We treat the areas as regions on the 2ドル$-dimensional plane. The boundary of each region is a 4ドル$-sided polygon with 2ドル$ edges parallel to the $x$-axis, and 2ドル$ edges parallel to the $y$-axis. In other words, each region has a rectangular boundary with $(x_1^i,y_1^i)$ as a lower left corner and $(x_2^i,y_2^i)$ as a upper right corner. The regions may overlap.

The cables must be constructed along the $x$-axis or the $y$-axis, due to safety issues. So the cost of constructing a cable from $(x_1,y_1)$ to $(x_2,y_2)$ is $\left |x_1-x_2\right |+\left |y_1-y_2\right |$ won.

A cable connecting two areas $A$ and $B$ should connect two points, one from each region.

Find the minimum sum of the cost for connecting $\binom{N}{2}$ cables between all pairs of the areas.

Note that the cables must be constructed for all $\binom{N}{2}$ pairs of areas. This means, for example, even if two endpoints of a cable belong to more than one pair of areas, we do not consider it as connecting all such pairs.

Since the answer can be large, output it modulo 998ドル,円 244,円 353$. It can be proved that the answer is always a non-negative integer.

입력

The first line contains one integer, $N$.

The $i$-th of the following $N$ lines contain space-separated four integers $x_1^i,ドル $y_1^i,ドル $x_2^i,ドル and $y_2^i$ — indicating the positions of the lower left and the upper right corners of the region representing the $i$-th area.

출력

Output a single integer — the minimum cost to construct all cables in the unit of won, modulo 998ドル,円 244,円 353$. 998ドル,円 244,円 353=119\times 2^{23}+1$ is a prime number.

제한

  • 2ドル\le N\le 300,円 000$
  • 0ドル\le x_1^i<x_2^i\le 998,円 244,円 352$ (1ドル\le i\le N$)
  • 0ドル\le y_1^i<y_2^i\le 998,円 244,円 352$ (1ドル\le i\le N$)

예제 입력 1

3
1 7 2 9
3 2 8 4
4 3 8 5

예제 출력 1

8

예제 입력 2

4
0 1 2 3
1 0 3 2
3 4 5 6
4 3 6 5

예제 출력 2

8

힌트

출처

University > KAIST > KAIST ICPC Mock Competition > 2022 KAIST 12th ICPC Mock Competition B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /