HDU 3720 Deep Search Enumeration

Source: Internet
Author: User

DES: From 23 players, 4-4-2-1 A total of 4 kinds of 11 people to form the competition team. Give everyone the ability to value each position. Gives an additional effect when the M group of people are together. Ask you the ability and the maximum of the whole game.

Use deep-search violence to enumerate each type of person selection. Feeling is this deep search write very witty.

There is a slow structure in the vector. TLE. The Direct deposit number is AC. In the future, we should try to use less structure.

#include <stdio.h>#include<string.h>#include<map>#include<vector>#include<iostream>using namespaceStd;vector<int>play[4];vector<int>ans;intpow[ -];map<string,int>Mtype;map<string,int>Mname;inteff[ +][ +];intMAXN =0;voidDFS2 (int,int );voidDFS3 (int,int );voidDFS4 (int,int );voidDFS1 (intPosintsum) {    if(Sum = =1) {DFS2 (-1,0); return; }     for(inti=pos+1; i<play[1].size (); ++i) {ans.push_back (play[1][i]); DFS1 (i, Sum+1);    Ans.pop_back (); }}voidDFS2 (intPosintsum) {    if(Sum = =4) {DFS3 (-1,0); return; }     for(inti=pos+1; i<play[2].size (); ++i) {ans.push_back (play[2][i]); DFS2 (i, Sum+1);    Ans.pop_back (); }}voidDFS3 (intPosintsum) {    if(Sum = =4) {DFS4 (-1,0); return; }     for(inti=pos+1; i<play[3].size (); ++i) {ans.push_back (play[3][i]); DFS3 (i, Sum+1);    Ans.pop_back (); }}voidDFS4 (intPosintsum) {    if(Sum = =2)    {        intAnss =0;  for(intI=0; I<ans.size (); ++i) { for(intj=i+1; J<ans.size (); ++j) {Anss+=Eff[ans[i]][ans[j]]; } anss+=Pow[ans[i]]; }        if(Anss >maxn) MAXN=Anss; return; }     for(inti=pos+1; i<play[0].size (); ++i) {ans.push_back (play[0][i]); DFS4 (i, Sum+1);    Ans.pop_back (); }}intMain () {mtype["goalkeeper"] =1; mtype["Defender"] =2; mtype["midfielder"] =3; mtype["striker"] =0; Charname[ +], type[ -]; intPower;  while(Cin >>name) {MAXN= -0x3f3f3f3f;        Ans.clear ();  for(intI=0; i<4; ++i) play[i].clear (); CIN>> Power >>type; inttt =Mtype[type]; pow[0] =Power; Mname[name]=0; Play[tt].push_back (0); memset (EFF,0,sizeof(EFF));  for(intI=1; i<= A; ++i) {cin>> name >> Power >>type; Pow[i]=Power; Mname[name]=i; inttt =Mtype[type];        Play[tt].push_back (i); }        intN; CIN>>N; intN1, N2, add; Charna1[ +], na2[ +];  for(intI=1; i<=n; ++i) {cin>> na1 >> Na2 >>add; N1=MNAME[NA1]; N2=MNAME[NA2]; EFF[N1][N2]=add; EFF[N2][N1]=add; }        inta[4] = {2,1,4,4}; BOOLFlag =true;  for(intI=0; i<4; ++i) {if(Play[i].size () <A[i]) {Flag=false;  Break; }        }        if(!flag) {cout<<"impossible\n"; Continue; } DFS1 (-1,0); cout<< MAXN <<Endl; }    return 0;}
Look

HDU 3720 Deep Search Enumeration

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.