codeforce之problems for round
来源:互联网 发布:淘宝买的鲜人参怎么样 编辑:程序博客网 时间:2024/06/08 08:17
题目:
There are n problems prepared for the next Codeforces round. They are arranged in ascending order by their difficulty, and no two problems have the same difficulty. Moreover, there are m pairs of similar problems. Authors want to split problems between two division according to the following rules:
- Problemset of each division should be non-empty.
- Each problem should be used in exactly one division (yes, it is unusual requirement).
- Each problem used in division 1 should be harder than any problem used in division 2.
- If two problems are similar, they should be used in different divisions.
Your goal is count the number of ways to split problem between two divisions and satisfy all the rules. Two ways to split problems are considered to be different if there is at least one problem that belongs to division 1 in one of them and to division 2 in the other.
Note, that the relation of similarity is not transitive. That is, if problem i is similar to problem j and problem j is similar to problem k, it doesn't follow that i is similar to k.
The first line of the input contains two integers n and m (2 ≤ n ≤ 100 000, 0 ≤ m ≤ 100 000) — the number of problems prepared for the round and the number of pairs of similar problems, respectively.
Each of the following m lines contains a pair of similar problems ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi). It's guaranteed, that no pair of problems meets twice in the input.
Print one integer — the number of ways to split problems in two divisions.
解答:
在每次输入的时候就已经能确认哪些要放入第一部分哪些放入第二部分,由此可以更新第一部分的能放的难度系数最大值和第二部分的能放的难度系数的最小值
由此可以最终判断是不是符合和最终的方案数
- codeforce之problems for round
- Problems for Round
- codeforcs 351 B. Problems for Round
- 【CodeForces】[673B]Problems for Round
- codeforcs 351 B. Problems for Round
- CodeForces 351 B Problems for Round
- 【Codeforces】 -673B - Problems for Round
- Codeforces 673B Problems for Round【思维】
- 【Codeforces Round #351 Div. 2】 673B Problems for Round
- 【Codeforces】351B - Problems for Round(思维,好题)
- CodeForces - 673B Problems for Round (模拟)水
- CodeForces 673B Problems for Round(比赛出题规则)
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) B.Problems for Round
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) B. Problems for Round
- CodeForce Round Table Knights
- codeforce round 175 div2
- codeforce round #217
- codeforce round#226 div2
- 深入浅出JMS(四)--Spring和ActiveMQ整合的完整实例
- Openfire问题记录
- 关于极光推送我做的工作
- Android中的动态加载机制
- Web服务器处理HTTP压缩之gzip、deflate压缩
- codeforce之problems for round
- QuartZ Cron表达式
- 治好颈椎病就这么简单
- C++this指针
- git 命令
- 查看sqlserver的端口号
- Android面试经验
- 说说梦想
- 关于ListView的item中包含Button或Checkbox时导致item无法点击问题