QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#10302. 天天爱下棋

الإحصائيات

小 Z 同学认为下棋非常有趣,于是决定制作一款叫做《天天爱下棋》的游戏。《天天爱下棋》是一个卡牌游戏,需要玩家将背包里的卡牌组合成一个卡组,与其他玩家进行 PK。

这个游戏的每张卡牌共有两个数值——攻击力和防御值,卡牌 A 可以击败卡牌 B 当且仅当卡牌 A 的攻击力大于等于卡牌 B 的防御值。

而这个游戏的卡组恰好由三张两两不同的卡牌组成,顺序放置在三个卡槽中。为了游戏的公平性,三张卡牌能组成一个卡组当且仅当:

  • 卡槽1对应的卡牌能击败卡槽2对应的卡牌
  • 卡槽2对应的卡牌能击败卡槽3对应的卡牌
  • 卡槽3对应的卡牌能击败卡槽1对应的卡牌

开发完成后,小 Z 同学邀请了小 H 同学帮忙测试,并赠予了他 $n$ 张初始卡牌。

现在小 H 想知道,他一共能组出多少种本质不同的卡组,两个卡组不同当且仅当至少存在一个卡槽所对应的卡牌不相同

输入格式

从标准输入读入数据。

输入第一行包含三个整数 $s, n$,分别表示子任务编号和卡牌个数。对于样例,$s$ 表示该样例与测试点 $s$ 拥有相同的限制条件。

接下来 $n$ 行,每行包含两个整数 $a_i,d_i$,分别表示第 $i$ 个卡牌的攻击力和防御值。

输出格式

输出到标准输出。

输出一个整数,表示小 H 一共能组出多少种本质不同的卡组。

样例

输入

1 10
7 4
18 18
10 15
12 3
12 15
9 7
10 1
3 19
11 7
8 13

输出

60

样例二

见下载目录下的 ex_2.inex_2.ans

该组样例满足子任务 4 的条件。

样例三

见下载目录下的 ex_3.inex_3.ans

该组样例满足子任务 6 的条件。

子任务

对于所有测试数据,保证 $1 \le n \le 2 \times 10^{5},\ 1\le a_i,d_i\le 2\times n$。

子任务得分$n\le$特殊性质
15500
22,000
3105,000
4$2 \times 10^{4}$
525$5 \times 10^{4}$
630$2 \times 10^{5}$
715

特殊性质:保证 $\forall 1\le i \le n, 1\le a_i, d_i \le 500$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.