zoukankan      html  css  js  c++  java
  • hdoj5813【构造】

    2016 Multi-University Training Contest 7 05
    真的真的好菜哇。。。
    思路:
    暴力。
    我对那些到达目的地少的点做硬性规定就是去比他要到达目的地更少的点,这样一来肯定是满足的嘛,题目也没要求输出路径的唯一,这个方法正好把某个点能到达的所有点都指了出来,就是这样啊。。。
    贴一发挫code…….

    #include <iostream>
    #include <cstdio>
    #include <string.h>
    #include <algorithm>
    using namespace std;
    typedef __int64 LL;
    
    const int N=1e3+10;
    
    struct asd{
        int num;
        int id;
    };
    asd q[N];
    
    bool cmp(asd x,asd y)
    {
        return x.num<y.num;
    }
    int x[N*N],y[N*N];
    int cnt;
    
    int main()
    {
        int t,cas=1,n;
        scanf("%d",&t);
        while(t--)
        {
            bool flag;
            scanf("%d",&n);
            for(int i=1;i<=n;i++)
            {
                scanf("%d",&q[i].num);
                q[i].id=i;
            }
            sort(q+1,q+n+1,cmp);
            printf("Case #%d: ",cas++);
            flag=true;
            cnt=0;
            for(int i=1;i<=n;i++)
            {
                if(q[i].num>=i)
                {
                    printf("No
    ");
                    flag=false;
                    break;
                }
                for(int j=1;j<=q[i].num;j++)
                {
                    x[cnt]=q[i].id;
                    y[cnt++]=q[j].id;
                }
            }
            if(!flag) continue;
            printf("Yes
    ");
            printf("%d
    ",cnt);
            for(int i=0;i<cnt;i++)
                printf("%d %d
    ",x[i],y[i]);
        }
        return 0;
    }
  • 相关阅读:
    淘宝网站
    CentOS 安装 gcc
    待整理
    待整理
    CentOS常用查看系统命令
    Oracle 分区字段数据更新
    MapReduce修改输出的文件名
    MapReduce分区的使用(Partition)
    使用JobControl控制MapReduce任务
    Centos安装ntfs
  • 原文地址:https://www.cnblogs.com/keyboarder-zsq/p/5934902.html
Copyright © 2011-2022 走看看