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

9030번 - Bridge 다국어채점 준비 중

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB0000.000%

문제

Recently, there was a big typhoon that swept away all the bridges between islands. What’s done is done. Anyway, we need to deploy the road network again. As an emergency recovery, the government decided to construct bridges such that people would move between any pair of islands without getting wet. The cost of deploying a bridge of length x is the square of x. Due to land reclamation, all islands are rectangular and their boundaries are parallel to lines of latitude or lines of longitude. Given the positions and shapes of islands, compute the minimum cost of connecting all islands.


Figure 1. The illustration of the second sample input

입력

The input contains several test cases. The first line of the input contains an integer number 1 ≤ T ≤ 20 that indicates the number of test cases. In each test case, the first line is an integer 2 ≤ N ≤ 5,000 indicating the number of islands. Each line of next N lines contains four positive integers 0 ≤ x, y, w, h ≤ 10,000 where x and y is the x and y coordinates of upper-left corner of the island, and w and h are the width and height of the island, respectively.

출력

For each test case, output an integer indicating the minimum cost of the construction in the manner described above.

제한

예제 입력 1

2
2
1 1 5 1
2 3 1 1
4
6 4 3 4
2 8 6 3
1 14 4 4
9 12 4 3

예제 출력 1

1
7

힌트

출처

ICPC > Regionals > Asia Pacific > Korea > Nationwide Internet Competition > Daejeon Nationalwide Internet Competition 2010 E번

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

출처

대학교 대회

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

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