UVa 140 带宽 Bandwidth

暴力题目

注意一下细节应该还是很好ac的;

因为题目太多图片和字了,我就决定不排版了。


Given a graph (V, E) where V is a set of nodes and E is a set of arcs inV ×V , and an ordering on the elements in V , then the bandwidth of anode v is defined as the maximum distance in the ordering between vand any node to which it is connected in the graph. The bandwidthof the ordering is then defined as the maximum of the individualbandwidths. For example, consider the graph on the right:

For these orderings, the bandwidths of the nodes (in order) are 6, 6, 1, 4, 1, 1, 6, 6 giving an orderingbandwidth of 6, and 5, 3, 1, 4, 3, 5, 1, 4 giving an ordering bandwidth of 5.Write a program that will find the ordering of a graph that minimises the bandwidth.

InputInput

 will consist of a series of graphs. Each graph will appear on a line by itself. The entire file willbe terminated by a line consisting of a single ‘#’. For each graph, the input will consist of a series ofrecords separated by ‘;’. Each record will consist of a node name (a single upper case character in thethe range ‘A’ to ‘Z’), followed by a ‘:’ and at least one of its neighbours. The graph will contain nomore than 8 nodes.

Output

Output will consist of one line for each graph, listing the ordering of the nodes followed by an arrow(->) and the bandwidth for that ordering. All items must be separated from their neighbours byexactly one space. If more than one ordering produces the same bandwidth, then choose the smallestin lexicographic ordering, that is the one that would appear first in an alphabetic listing.

Sample Input

A:FB;B:GC;D:GC;F:AGH;E:HD#

Sample Output

A B C F G D H E -> 3


写的时候因为思路换过一次,有些之前思路用到的定义也还没有来得及删,大家就凑活着看吧

include <map>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    //freopen("out.txt","w",stdout);
    char s[100];
    while(~scanf("%s",s))
    {
        if(s[0]=='#')break;
        map<char,int>p;                  
        int k=0,jl[10],ans[10]={0};   //ans就答案
        int lj[27][27]={0};           //表示两个字母是否链接的标记数组,虽然节点只有不到10个,可是这里必须定义27满足26个字母,我之前就是这里定义少了,狂错。
        int len=strlen(s);

        for(int i=0;i<len;i++)
        {
            if(isalpha(s[i]))
            {
                if(!p.count(s[i])){p[s[i]]=1;jl[k++]=s[i]-'A';}
            }
            else
            {
                if(s[i]==':')
                {
                    for(int j=i+1;s[j]!=';'&&s[j]!='\0';j++)
                    {
                        if(s[i]==' ')continue;
                        lj[s[j]-'A'][s[i-1]-'A']=1;          //记录,由于这题的链接是无序的,所以必须两边都要标记
                        lj[s[i-1]-'A'][s[j]-'A']=1;

                    }
                }
            }
        }
        sort(jl,jl+k);
        int minn=999999;
        do{
            int d=-1,f=0;
            int z;
            for(int i=0;i<k;i++)
            {
                for(int j=i+1;j<k;j++)
                {
                    if(lj[jl[i]][jl[j]]==1) z=j-i;    //诶,这应该是找到了
                    if(z>d) d=z;
                    if(d>minn){f=1;break;}
                }
                if(f==1)break;                        //用f来判断是否要剪枝,来减小重复多余的循环

            }
            if(f==1)continue;
            if(d<minn)
            {
                minn=d;
                for(int i=0;i<k;i++)
                    ans[i]=jl[i];
            }
        }while(next_permutation(jl,jl+k));    //用next_permutatio函数进行全排列,然后比较取得最大的一次带宽


        for(int i=0;i<k;i++)
            printf("%c ",ans[i]+'A');
        printf("-> %d\n",minn);

        memset(s,0,sizeof(s));

    }
    return 0;
}


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
带宽扩展是指通过某种方法将音频信号的频带范围扩展到更宽的范围,从而提高音质和听感。引用中的研究提出了一种使用深度神经网络进行宽带频谱包络估计的人工语音带宽扩展方法。该算法属于盲带宽扩展算法,即在没有原始音频的情况下进行扩展。通过该方法,可以在有限的音频条件下实现更宽范围的音频效果。引用中的系统实现图示了该算法的基本结构。另外,引用中提到了传统的传输信道对带宽和语音质量的限制,而带宽扩展方法可以通过不升级基础设施的方式,在所有通信节点代替扩展传入语音信号的带宽,提高通信质量。他们提出了一个基于WaveNet的模型,该模型是一个音频波形的深度生成模型,用于实现带宽扩展的目标。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Speech Bandwidth Extension With WaveNet](https://blog.csdn.net/qq_34218078/article/details/103725772)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Audio Bandwidth Extension](https://blog.csdn.net/qq_34218078/article/details/85043154)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值