# 【Codeforces Round #351 Div. 2】 673B Problems for Round

73人阅读 评论(0)

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.

【题目分析】

【代码】

#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
int main()
{
int n,m;
scanf("%d%d",&n,&m);
int lmax=1,rmin=n;
for (int i=1;i<=m;++i){
int u,v;
scanf("%d%d",&u,&v);
lmax=max(min(u,v),lmax);
rmin=min(max(u,v),rmin);
}
if (lmax>=rmin) {
printf("0\n"); return 0;
}
else {
printf("%d\n",rmin-lmax); return 0;
}
}
0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：70823次
• 积分：5550
• 等级：
• 排名：第4941名
• 原创：505篇
• 转载：1篇
• 译文：0篇
• 评论：43条
联系方式
QQ:3052857822
Email:Orion_Rigel@outlook.com