首页 > 其他 > 详细

codeforces 639B Bear and Forgotten Tree 3

时间:2016-10-06 00:26:13      阅读:301      评论:0      收藏:0      [点我收藏+]

细节不少的构造题。

#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

原文:http://www.cnblogs.com/ziliuziliu/p/5933224.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!