codeforces755E PolandBall and White-Red graph -- 构造
来源:互联网 发布:天刀女性捏脸数据下载 编辑:程序博客网 时间:2024/05/29 09:25
传送门
题目大意:
构造一个
我们先证明一个结论:如果图
证明:
令
- 若
x 与y 都在P 中:如果x 与y 都在S 中,那么在G′ 中一定存在一条x→v→y 的路径。在T 中同理。否则如果一个在S 中,一个在T 中,那么在G 中x 与y 一定不相邻,在G′ 中一定相邻。于是x 与y 的距离小于3 。 - 若
x 与y 都在Q 中:如果x 或y 就是u ,那么在G′ 中x 与y 一定相邻。否则G′ 中一定存在一条x→u→y 的路径。于是x 与y 的距离小于3 。 - 若
x 在P 中,y 在Q 中:如果x 在S 中,那么在G′ 中一定存在一条x→v→y 的路径。在T 中同理。于是x 与y 的距离小于3 。
这样就证完了。
显然
当
显然如果连成一条链,
当
将前
代码:
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;int i,j,k,n,m,p;int main(){ scanf("%d%d",&n,&k); if(n<4||k==1||k>3){ puts("-1"); return 0; } if(k==3){ printf("%d\n",n-1); printf("1 2\n2 3\n"); for(i=4;i<=n;i++)printf("%d %d\n",3,i); return 0; } if(n==4)puts("-1");else{ printf("%d\n",n-1); for(i=2;i<=n;i++)printf("%d %d\n",i-1,i); } return 0;}
阅读全文
1 0
- codeforces755E PolandBall and White-Red graph -- 构造
- codeforces 755E PolandBall and White-Red graph
- 图论(PolandBall and White-Red graph,cf 755E)
- 8VC Venture Cup 2017 - Elimination Round E. PolandBall and White-Red graph【枚举思维】
- hdu 5113 Black and White(贪心构造)
- A. PolandBall and Hypothesis
- Codeforces 623A Graph and String (构造)
- codeforces755B. PolandBall and Game(map)
- 755A PolandBall and Hypothesis
- 755B PolandBall and Game
- rearrange array (red, white, blue)
- codeforcces 623A - Graph and String Note that 构造
- Codeforces 841D Leha and another game about graph 构造
- 【codeforces 755A】PolandBall and Hypothesis
- 【codeforces 755B】PolandBall and Game
- 【codeforces 755C】PolandBall and Forest
- 【codeforces 755D】PolandBall and Polygon
- codeforces-755-B PolandBall and Game
- C语言模式实现C++继承和多态
- 初入H5
- Java笔记(三) 面向对象编程
- MongoDB五(更新与删除文档)
- 关于nginx环境不能解析TP路由的问题
- codeforces755E PolandBall and White-Red graph -- 构造
- kotlin实现简单Rxjava operator原理
- Why / When / How should I use exception in Python ?
- Python学习笔记(2)Python对excel文件的操作
- 数学建模_使用网络分析法(ANP模型)解决美日欧系车型的选择问题
- Sorebrect勒索病毒分析报告
- LinkedHashMap、HashMap、HashTable、TreeMap、ConcurrentHashMap的比较
- linux swap分区作用
- mac多版本python安装 pymysql