zoukankan      html  css  js  c++  java
  • HDU 3118 Arbiter

    Arbiter

    Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
    Total Submission(s): 1332    Accepted Submission(s): 664

    Problem Description
    Arbiter is a kind of starship in the StarCraft science-fiction series. The Arbiter-class starship is a Protoss warship specializing in providing psychic support. Arbiters were crewed exclusively by Judicators; unlike other warships that were manned predominantly by Templar. The Judicator used the Arbiter as a base to provide support using space-time manipulation.
    Arbiters could weaken space-time, tearing rifts in the fabric of space-time, creating a vortex linking another location to the Arbiter’s location. This could be used to move personnel over long distances between stars.
    In the meantime of widely used Arbiter to transfer, KMXS, the captain of one Arbiter, was warning that some person had got a serious mental disorder after the trip on his Arbiter. By using mice as model animals, he found the sake, it’s because of chirality!
    Every person has chirality, either left-handed or right-handed. Actually all the persons must live with the food which has the same chirality. When one person took Arbiter from one star to another one, his chirality will be changed (from left-handed to right-handed or from right-handed to left-handed). If a person took a long trip and finally got back to his own star, however, his chirality might be changed to the opposite state other than his original, which would cause fatal mental disorder, or even death. 
    KMXS has the channels map among the starts and he need to prohibit minimum number of channels from traveling so that wherever a person starts his traveling from when he gets his original star he’ll be safe. KMXS turns to your help.
     
    Input
    The first line of input consists of an integer T, indicating the number of test cases.
    The first line of each case consists of two integers N and M, indicating the number of stars and the number of channels. Each of the next M lines indicates one channel (u, v) which means there is a bidirectional channel between star u and star v (u is not equal to v).
     
    Output
    Output one integer on a single line for each case, indicating the minimum number of channels KMXS must prohibit to avoid mental disorder.

    Constraints
    0 < T <= 10
    0 <= N <= 15 0 <= M <= 300
    0 <= u, v < N and there may be more than one channel between two stars.
     
    Sample Input
    1 3 3 0 1 1 2 2 0
     
    Sample Output
    1
     
    Source
     
    Recommend
    lcy   |   We have carefully selected several similar problems for you:  3126 3124 3123 3120 3125 
    思路:二分图,枚举。
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    int T,n,m,map[20][20],fa[20],a[20],b[20],ans;
    int main(){
        scanf("%d",&T);
        while(T--){
            memset(map,0,sizeof(map));
            scanf("%d%d",&n,&m);
            for(int i=1;i<=m;i++){
                int x,y;
                scanf("%d%d",&x,&y);
                x+=1;y+=1;
                map[x][y]++;
                map[y][x]++;
            }
            ans=0x7f7f7f7f;
            for(int i=0;i<(1<<n);i++){//n个点分成两边,有2^n种分法。 
                int maxn=0;
                int sa=0,sb=0;
                memset(a,0,sizeof(a));
                memset(b,0,sizeof(b));
                for(int j=1;j<=n;j++)
                    if(i&(1<<(j-1)))    a[++sa]=j;
                    else b[++sb]=j;
                for(int j=1;j<=sa;j++)
                    for(int k=j+1;k<=sa;k++)
                        if(map[a[j]][a[k]]) maxn+=map[a[j]][a[k]]; 
                for(int j=1;j<=sb;j++)
                    for(int k=j+1;k<=sb;k++)
                        if(map[b[j]][b[k]])    maxn+=map[b[j]][b[k]];
                ans=min(ans,maxn);
            }
            printf("%d
    ",ans);
        }
    }
    细雨斜风作晓寒。淡烟疏柳媚晴滩。入淮清洛渐漫漫。 雪沫乳花浮午盏,蓼茸蒿笋试春盘。人间有味是清欢。
  • 相关阅读:
    .net日期类与UNIX时间戳的相互转换,长数字
    钉钉的生日模块在哪
    js判断手机是苹果(IOS)还是安卓(android) H5手机端自适应宽高
    .net网站部署winserver2008R2 IIS只列出目录 浏览只显示目录浏览
    ajax有时请求不到数据 后台,有时收不到返回值的解决办法
    overflow不超出时不显示滚动条 属性解决内容未超出依然显示滚动条轨道的问题
    PB取datawindow生成的语句。要在datawindow的sqlpreview事件
    电脑C盘缓存路径在哪,清理C盘哪个文件夹可以删
    PB里执行写SQL语句
    SQL SERVER合并行。将多行数据合并成一行,字符串拼接
  • 原文地址:https://www.cnblogs.com/cangT-Tlan/p/7436428.html
Copyright © 2011-2022 走看看