codeforce之problems for round

原创 2016年05月31日 10:10:25

题目:

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.

Input

The first line of the input contains two integers n and m (2 ≤ n ≤ 100 0000 ≤ 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.

Output

Print one integer — the number of ways to split problems in two divisions.

解答:

在每次输入的时候就已经能确认哪些要放入第一部分哪些放入第二部分,由此可以更新第一部分的能放的难度系数最大值和第二部分的能放的难度系数的最小值

由此可以最终判断是不是符合和最终的方案数

Codeforces 673B Problems for Round【思维】

B. Problems for Round time limit per test 2 seconds memory limit per test 256 megabytes i...

Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) B.Problems for Round

B. Problems for Round time limit per test 2 seconds memory limit per test 256 megabytes ...

codeforce : Educational Codeforces Round 22

A. The Contest 题目大意: 输入一个整数n表示有n个数,然后输入n个数表示这小子解决每个题所用的时间,当然同一时间只能想一个问题,然后他得交题,然后输入m,然后输入m个有序对,表示m...

codeforce round 175 div2

哎,这次的cf题比较简单的说,但是还是很粗心,只做出来两题,先说说我做的两题吧。水题两枚。 这次的主题是permutation,permutation就是一个有序的正整数集合:p1,p2,p3...p...

Codeforce Round #379 (Div. 2) 734 E Anton and Tree(tree 缩点 树的直径 )

题目链接734 E Anton and Tree 题目大意:一棵树上有两种不同颜色的节点,你有一种操作,一次可以改变与vv相连的同种颜色联通快的颜色,问最少多少次操作可以把树染成同样的颜色分析看了题...

Codeforces Round #128 (Div. 2) A. Two Problems

A. Two Problems time limit per test 2 seconds memory limit per test 256 megabytes input standa...

codeforce round412 div2 C sucess rate 数学|二分

记住当你觉得很苦很累的时候,你真的在进步!
  • Na_OH
  • Na_OH
  • 2017年05月09日 16:21
  • 232

codeforce round#411div2

Codeforces Round #411 (Div. 2) A. Fake NP time limit per test 1 second memory limit per t...
  • Jamence
  • Jamence
  • 2017年05月06日 10:11
  • 453

【CodeForce】Codeforces Round #140 (Div. 2) A B C

第一次做CF上面的题目,感觉跟平常做的题目有一点不同,抽象的问题很多,需要优秀的数学逻辑将其转化为我们见过的算法模型。 CF比赛连接 http://codeforces.com/contest/22...

【CodeForce】Codeforces Round #141 (Div. 2) B. Two Tables

第二次熬夜做题,发现这一次的阅读量好大,英语差的连题目都看不懂。。。好不容易看懂了一个,代码写了我两个小时,哎.....不解释了。 CF比赛连接 Codeforces Round #141 (Div...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:codeforce之problems for round
举报原因:
原因补充:

(最多只允许输入30个字)