UVA-140 Bandwidth (bandwidth) (full array)

Source: Internet
Author: User

Test instructions: For the given graph, the nodes with the least bandwidth are arranged.

Analysis: The number of nodes is up to 8, all arranged. The vertex range is a~z.

#pragmaComment (linker, "/stack:102400000, 102400000")#include<cstdio>#include<cstring>#include<cstdlib>#include<cctype>#include<cmath>#include<iostream>#include<sstream>#include<iterator>#include<algorithm>#include<string>#include<vector>#include<Set>#include<map>#include<stack>#include<deque>#include<queue>#include<list>#defineMin (A, B) ((a < b) a:b)#defineMax (A, B) ((a < b)? b:a)typedefLong Longll;typedef unsignedLong LongLlu;Const intInt_inf =0x3f3f3f3f;Const intInt_m_inf =0x7f7f7f7f;Constll ll_inf =0x3f3f3f3f3f3f3f3f;Constll ll_m_inf =0x7f7f7f7f7f7f7f7f;Const intDr[] = {0,0, -1,1, -1, -1,1,1};Const intDc[] = {-1,1,0,0, -1,1, -1,1};Const intMOD = 1e9 +7;Const DoublePI = ACOs (-1.0);Const DoubleEPS = 1e-8;Const intMAXN = -+Ten;Const intMaxt =10000+Ten;using namespacestd;CharS[MAXN];Set<int> node[ -];vector<int>v;intt[Ten];voidinit () { for(inti =0; I < -; ++i)    {node[i].clear ();    } v.clear (); memset (T,0,sizeoft); intLen =strlen (s);  for(inti =0; i < Len; ++i) {        if(S[i] = =':'){            intTMP = S[i-1] -'A';  while(1){                ++i; if(i = = len) Break; if(S[i] = =';') Break; Node[tmp].insert (S[i]-'A'); Node[s[i]-'A'].insert (TMP); }        }    }}intMain () { while(SCANF ("%s", s) = =1){        if(s[0] =='#')return 0;        Init ();  for(inti =0; I < -; ++i) {            if(Node[i].size ()) {v.push_back (i); }        }        intLen =v.size (); intAns =Int_m_inf;  Do{            intTMP =0;  for(inti =0; i < Len; ++i) {                 for(intj =0; J < I; ++j) {                    if(Node[v[i]].count (V[j])) {tmp= MAX (tmp, I-j); }                }            }            if(TMP <ans) {ans=tmp;  for(inti =0; i < Len; ++i) {T[i]=V[i]; }            }        } while(Next_permutation (V.begin (), V.end ()));  for(inti =0; i < Len; ++i) {printf ("%c",'A'+T[i]); } printf ("%d\n", ans); }    return 0;}

UVA-140 Bandwidth (bandwidth) (full array)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.