HDU 4068 Fuzhou Division Network Race H arrangement * * *

Source: Internet
Author: User

It's too slow, I'm not satisfied.

After the order, enumerate yourself and the opponent state, if defeated, then enumerate their next strategy, until they can defeat all the strategy of the opponent

#include <cstdio>#include<iostream>#include<algorithm>#include<cstring>#include<cmath>#include<queue>#include<map>using namespacestd;#defineMOD 1000000007Const intinf=0x3f3f3f3f;Const Doubleeps=1e-5; typedefLong Longll;#defineCL (a) memset (A,0,sizeof (a))#defineTS printf ("*****\n");Const intmaxn=1005;intN,m,tt;intg[ the][ the];inta1[ the]={0,1,2,3,4,5,6};inta2[ the]={0,1,2,3,4,5,6};BOOLCheck () {intt1=0; intT2=0; BOOLflag=0;  while(1)    {        if(G[a2[t2]][a1[t1]]) {T1++; }        Elset2++; if(t1==N) {flag=0;  Break; }        if(t2==N) {flag=1;  Break; }    }    if(!flag)return 0; Else return 1;}intMain () {intI,j,k,ca=1; #ifndef Online_judge Freopen ("1.in","R", stdin); #endifscanf ("%d",&TT);  while(tt--) {printf ("Case %d:", ca++); Map<string,int>MP1; Map<int,string>MP2; scanf ("%d",&N); strings[ the];  for(i=0; i<n;i++) {cin>>S[i]; } sort (S,s+N);  for(i=0; i<n;i++) {Mp1[s[i]]=i; Mp2[i]=S[i];        } cl (g); stringSW;  for(i=0; i<n;i++)        {            intnum; scanf ("%d",&num);  for(j=0; j<num;j++) {cin>>SW; intv=MP1[SW]; G[I][V]=1;//have a restraining relationship            }        }         for(i=0;i< the; i++) a1[i]=i,a2[i]=i; BOOLflag=1; BOOLw=0;  while(1) {flag=1;  while(1)            {                if(!check ())//the strategy was defeated{flag=0; }                if(!next_permutation (A2,a2+n)) Break; }            if(flag) {W=1;  Break; }            if(!next_permutation (A1,a1+n)) Break; }        if(W) {printf ("yes\n"); cout<<mp2[a1[0]];  for(i=1; i<n;i++) {cout<<" "<<Mp2[a1[i]]; } printf ("\ n"); }        Else{printf ("no\n"); }    }}

HDU 4068 Fuzhou Division Network Race H arrangement * * *

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.