codeforces 639B Bear and Forgotten Tree 3
Posted ziliuziliu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了codeforces 639B Bear and Forgotten Tree 3相关的知识,希望对你有一定的参考价值。
细节不少的构造题。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n,d,h,p=1,ret=1; int main() { scanf("%d%d%d",&n,&d,&h); if (2*h<d) {printf("-1\n");return 0;} if (d==1) { if (n==2) printf("1 2\n"); else printf("-1\n"); return 0; } for (int i=1;i<=h;i++) printf("%d %d\n",i,i+1); p=h+2; for (int i=1;i<=d-h;i++) { printf("%d %d\n",ret,p); ret=p;p++; } if (p!=n+1) { if (d!=h) { for (int i=p;i<=n;i++) printf("1 %d\n",i); } else { for (int i=p;i<=n;i++) printf("2 %d\n",i); } } return 0; }
以上是关于codeforces 639B Bear and Forgotten Tree 3的主要内容,如果未能解决你的问题,请参考以下文章
codeforces 653B B. Bear and Compressing(dfs)
Codeforces-A. Bear and Game(模拟)
Codeforce 573A. Bear and Poker
codeforces 653A A. Bear and Three Balls(水题)