CF815D.Karen and Cards

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Karen just got home from the supermarket, and is getting ready to go to sleep.

After taking a shower and changing into her pajamas, she looked at her shelf and saw an album. Curious, she opened it and saw a trading card collection.

She recalled that she used to play with those cards as a child, and, although she is now grown-up, she still wonders a few things about it.

Each card has three characteristics: strength, defense and speed. The values of all characteristics of all cards are positive integers. The maximum possible strength any card can have is pp , the maximum possible defense is qq and the maximum possible speed is rr .

There are nn cards in her collection. The ii -th card has a strength aia_{i} , defense bib_{i} and speed cic_{i} , respectively.

A card beats another card if at least two of its characteristics are strictly greater than the corresponding characteristics of the other card.

She now wonders how many different cards can beat all the cards in her collection. Two cards are considered different if at least one of their characteristics have different values.

输入格式

The first line of input contains four integers, nn , pp , qq and rr ( 1<=n,p,q,r<=5000001<=n,p,q,r<=500000 ), the number of cards in the collection, the maximum possible strength, the maximum possible defense, and the maximum possible speed, respectively.

The next nn lines each contain three integers. In particular, the ii -th line contains aia_{i} , bib_{i} and cic_{i} ( 1<=ai<=p1<=a_{i}<=p , 1<=bi<=q1<=b_{i}<=q , 1<=ci<=r1<=c_{i}<=r ), the strength, defense and speed of the ii -th collection card, respectively.

输出格式

Output a single integer on a line by itself, the number of different cards that can beat all the cards in her collection.

输入输出样例

  • 输入#1

    3 4 4 5
    2 2 5
    1 3 4
    4 1 1
    

    输出#1

    10
    
  • 输入#2

    5 10 10 10
    1 1 1
    1 1 1
    1 1 1
    1 1 1
    1 1 1
    

    输出#2

    972
    

说明/提示

In the first test case, the maximum possible strength is 44 , the maximum possible defense is 44 and the maximum possible speed is 55 . Karen has three cards:

  • The first card has strength 22 , defense 22 and speed 55 .
  • The second card has strength 11 , defense 33 and speed 44 .
  • The third card has strength 44 , defense 11 and speed 11 .

There are 1010 cards that beat all the cards here:

  1. The card with strength 33 , defense 33 and speed 55 .
  2. The card with strength 33 , defense 44 and speed 22 .
  3. The card with strength 33 , defense 44 and speed 33 .
  4. The card with strength 33 , defense 44 and speed 44 .
  5. The card with strength 33 , defense 44 and speed 55 .
  6. The card with strength 44 , defense 33 and speed 55 .
  7. The card with strength 44 , defense 44 and speed 22 .
  8. The card with strength 44 , defense 44 and speed 33 .
  9. The card with strength 44 , defense 44 and speed 44 .
  10. The card with strength 44 , defense 44 and speed 55 .

In the second test case, the maximum possible strength is 1010 , the maximum possible defense is 1010 and the maximum possible speed is 1010 . Karen has five cards, all with strength 11 , defense 11 and speed 11 .

Any of the 972972 cards which have at least two characteristics greater than 11 can beat all of the cards in her collection.

首页