CF815D.Karen and Cards

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:512MB

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 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.

凯伦刚从超市回到家,正准备睡觉。

洗完澡、换上睡衣后,她望向书架,发现了一本相册。出于好奇,她打开相册,看到了一套交易卡牌。

她回想起自己小时候曾玩过这些卡牌;尽管如今已长大成人,她仍对这套卡牌怀有一些疑问。

每张卡牌具有三项属性:力量(strength)、防御(defense)和速度(speed)。所有卡牌的所有属性值均为正整数。任意卡牌的力量最大可能值为 pp,防御最大可能值为 qq,速度最大可能值为 rr。

她的收藏中共有 nn 张卡牌。第 ii 张卡牌的力量、防御和速度分别为 aia_i、bib_i 和 cic_i。

当一张卡牌在至少两项属性上严格大于另一张卡牌的对应属性时,称这张卡牌击败另一张卡牌。

她现在想知道:有多少种不同的卡牌能够击败她收藏中的所有卡牌?若两张卡牌在至少一项属性上的取值不同,则认为它们是不同的卡牌。

输入格式

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.

输入的第一行包含四个整数 nn、pp、qq 和 rr(1 ≤ n, p, q, r ≤ 5000001 ≤ n, p, q, r ≤ 500000),分别表示卡牌收藏中的卡牌数量、最大可能的攻击力、最大可能的防御力以及最大可能的速度。

接下来的 nn 行,每行包含三个整数。具体而言,第 ii 行包含 aia_i、bib_i 和 cic_i(1 ≤ ai ≤ p1 ≤ a_i ≤ p,1 ≤ bi ≤ q1 ≤ b_i ≤ q,1 ≤ ci ≤ r1 ≤ c_i ≤ r),分别表示第 ii 张收藏卡牌的攻击力、防御力和速度。

输出格式

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 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.

在第一个测试用例中,最大可能的力量值为 4,最大可能的防御值为 4,最大可能的速度值为 5。Karen 拥有三张卡牌:

  • 第一张卡牌的力量为 2,防御为 2,速度为 5。
  • 第二张卡牌的力量为 1,防御为 3,速度为 4。
  • 第三张卡牌的力量为 4,防御为 1,速度为 1。

共有 10 张卡牌能击败此处所有的卡牌:

  1. 力量为 3、防御为 3、速度为 5 的卡牌。
  2. 力量为 3、防御为 4、速度为 2 的卡牌。
  3. 力量为 3、防御为 4、速度为 3 的卡牌。
  4. 力量为 3、防御为 4、速度为 4 的卡牌。
  5. 力量为 3、防御为 4、速度为 5 的卡牌。
  6. 力量为 4、防御为 3、速度为 5 的卡牌。
  7. 力量为 4、防御为 3、速度为 2 的卡牌。
  8. 力量为 4、防御为 4、速度为 3 的卡牌。
  9. 力量为 4、防御为 4、速度为 4 的卡牌。
  10. 力量为 4、防御为 4、速度为 5 的卡牌。

在第二个测试用例中,最大可能的力量值为 10,最大可能的防御值为 10,最大可能的速度值为 10。Karen 拥有五张卡牌,每张卡牌的力量、防御和速度均为 1。

所有 972 张至少有两个属性大于 1 的卡牌均能击败她收藏中的全部卡牌。

输入解题思路,AI测评打分。不知道怎么写?

首页