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

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

Territories

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

요약
각 종은 금지된 직사각형 밖에 배치해야 하며, 같은 칸에 모인 쌍의 수가 최대가 되도록 모든 동물을 배치한다.
난이도

보통10점 중 7점

유형
그리디, 정렬, 누적 합, 구현
정답자
아직 제출이 없습니다

문제

This time Byteasar researches a wildlife in a nature reserve that has a shape of an X×YX \times Y rectangle. It is divided into XYXY unit squares, there is a square with coordinates (x,y)(x, y) for every 1≤x≤X1 \le x \le X and 1≤y≤Y1 \le y \le Y.

Our hard-working researcher distinguished nn species of animals and discovered that each species dislikes living on some particular rectangle (which is stricly smaller than whole nature reserve). For species number ii it is rectangle described by its two opposite corners (x_i,y_i)(x\_i, y\_i) and (x′_i,y′_i)(x'\_i, y'\_i), for some x_i≤x′_ix\_i \leq x'\_i and y_i≤y′_iy\_i \leq y'\_i. We know that there are c_ic\_i animals in that species. Therefore, there are S=c_1+c_2+…+c_nS = c\_1 + c\_2 + \ldots + c\_n animals in total.

Byteasar has an idea for a social-natural experiment which relies on putting each of SS animals in some cell outside of its disliked region. Sociality of a placement is a number of pairs of animals so that both of them are in the same cell. Hence, if a cell contains pp animals, this adds p(p−1)2\frac{p(p-1)}{2} to the overall sociality.

It is allowed to put animals from the same species into different cells.

Find the maximum value of the sociality that can be attained.

입력

The first line of input contains three integers nn, XX and YY (1≤n≤100,0001 \leq n \leq 100\\,000, 1≤X,Y≤10001 \leq X,Y \leq 1000) denoting the number of species and dimensions of nature reserve, respectively.

Each of following nn lines contains a description of species, ii-th of them contains five integers x_i,y_i,x′_i,y′_i,c_ix\_i, y\_i, x'\_i, y'\_i, c\_i (1≤x_i≤x′_i≤X1 \leq x\_i \leq x'\_i \leq X, 1≤y_i≤y′_i≤Y1 \leq y\_i \leq y'\_i \leq Y, 1≤c_i≤10001 \leq c\_i \leq 1000) describing region disliked by species number ii and number of animals in that species. For each ii at least one of the following conditions holds: x_i≠1x\_i \neq 1, y_i≠1y\_i \neq 1, x′_i≠Xx'\_i \neq X, y′_i≠Yy'\_i \neq Y

출력

You need to print one integer -- the maximum possible sociality of some placement.

힌트

In first sample we need to put four animals in a cell (1,1)(1, 1) (contributing 4⋅32=6\frac{4 \cdot 3}{2} = 6 to the sociality) and put three remaining animals in a cell (1,2)(1, 2) (contributing 3⋅22=3\frac{3 \cdot 2}{2} = 3 to the sociality).

Second sample test is depicted below. All animals can be put in a cell (4,1)(4, 1).

예제2

  1. 예제 1

    입력
    2 1 2
    1 1 1 1 3
    1 2 1 2 4
    
    예상 출력
    9
    
  2. 예제 2

    입력
    3 7 3
    1 1 3 3 1
    5 1 7 3 1
    3 2 5 3 1
    
    예상 출력
    3