QOJ.ac

QOJ

時間限制: 2.0 s 記憶體限制: 512 MB 總分: 100

#15806. 混合饮料

统计

有 $n$ 种饮料。第 $i$ 种饮料的甜度、酸度和苦度分别为 $a_i, b_i, c_i$。如果你混合 $k$ 种(甜度、酸度、苦度)分别为 $(p_1, q_1, r_1), \dots, (p_k, q_k, r_k)$ 的饮料,那么混合后饮料的甜度、酸度和苦度将为 $(\max\{p_1, \dots, p_k\}, \max\{q_1, \dots, q_k\}, \max\{r_1, \dots, r_k\})$。

Snuke 决定从这 $n$ 种饮料中选择一种或多种进行混合,从而制作出一种新的饮料。求 Snuke 制作出的新饮料的(甜度、酸度、苦度)可能的三元组组合数量。保证 $(a_1, \dots, a_n)$、$(b_1, \dots, b_n)$、$(c_1, \dots, c_n)$ 分别是 $(1, \dots, n)$ 的一个排列。

输入格式

输入的第一行包含一个整数 $n$。接下来的 $n$ 行中,第 $i$ 行包含三个整数 $a_i, b_i$ 和 $c_i$。

数据范围

  • $1 \le n \le 10^5$
  • $(a_1, \dots, a_n), (b_1, \dots, b_n), (c_1, \dots, c_n)$ 是 $(1, \dots, n)$ 的排列。

输出格式

输出可能的甜度、酸度和苦度组合的数量。

样例

输入格式 1

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

输出格式 1

8

输入格式 2

10
3 1 3
7 8 2
10 10 5
1 3 9
9 2 4
5 7 6
4 6 10
8 5 1
6 9 7
2 4 8

输出格式 2

72

说明

在第一个样例中,例如,如果你混合第二种和第四种饮料,新饮料的甜度、酸度和苦度将为 $(3, 3, 4)$。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.