Codeforces Round 419 (Div. 1)
D
Karen and Cards
Codeforces
2800
原题
← CE →
翻译中…

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

翻译中…

image

翻译中…

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 $*p*$, the maximum possible defense is $*q*$ and the maximum possible speed is $*r*$.

翻译中…

There are $*n*$ cards in her collection. The $*i*$-th card has a strength $*a*_{*i*}$, defense $*b*_{*i*}$ and speed $*c*_{*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.

翻译中…

Input

翻译中…

The first line of input contains four integers, $*n*$, $*p*$, $*q*$ and $*r*$ ($1 ≤ *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 $*n*$ lines each contain three integers. In particular, the $*i*$-th line contains $*a*_{*i*}$, $*b*_{*i*}$ and $*c*_{*i*}$ ($1 ≤ *a*_{*i*} ≤ *p*$, $1 ≤ *b*_{*i*} ≤ *q*$, $1 ≤ *c*_{*i*} ≤ *r*$), the strength, defense and speed of the $*i*$-th collection card, respectively.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

In the first test case, the maximum possible strength is $4$, the maximum possible defense is $4$ and the maximum possible speed is $5$. Karen has three cards:

翻译中…
  • The first card has strength $2$, defense $2$ and speed $5$.
  • The second card has strength $1$, defense $3$ and speed $4$.
  • The third card has strength $4$, defense $1$ and speed $1$.
翻译中…

There are $10$ cards that beat all the cards here:

翻译中…
  1. The card with strength $3$, defense $3$ and speed $5$.
  2. The card with strength $3$, defense $4$ and speed $2$.
  3. The card with strength $3$, defense $4$ and speed $3$.
  4. The card with strength $3$, defense $4$ and speed $4$.
  5. The card with strength $3$, defense $4$ and speed $5$.
  6. The card with strength $4$, defense $3$ and speed $5$.
  7. The card with strength $4$, defense $4$ and speed $2$.
  8. The card with strength $4$, defense $4$ and speed $3$.
  9. The card with strength $4$, defense $4$ and speed $4$.
  10. The card with strength $4$, defense $4$ and speed $5$.
翻译中…

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

翻译中…

Any of the $972$ cards which have at least two characteristics greater than $1$ can beat all of the cards in her collection.

翻译中…

样例

Input #1
3 4 4 5
2 2 5
1 3 4
4 1 1
Output #1
10
InputCopy OutputCopy
Input #2
5 10 10 10
1 1 1
1 1 1
1 1 1
1 1 1
1 1 1
Output #2
972
InputCopy OutputCopy
题目信息
题号
815D
时间限制
2 s
内存限制
512 MB
标签
二分
组合数学
数据结构
计算几何

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。