2019 cattle off more second field school

F:

  The meaning of problems: 2n given individual, the presence of a value for each of two competitive world VI, jv_ {I, J} V I , J , questions asked these individuals divided into 2n n in each group of people, where a good score in all groups disorder of the (x, y) (x, y from different groups) produced VX, yv_ {X, Y} V X , Y , and is F, i.e., this problem is required minimum number F

  Solution: search violence, even to over ......

#include <bits / STDC ++ H.>
 the using  namespace STD; 
typedef Long  Long LL; 

int the Map [ 30 ] [ 30 ];
 int A [ 30 ], B [ 30 ]; 
LL SUM, ANS, n-; 

void DFS ( int PA , int Pb, LL Tsum) 
{ 
    IF (Tsum <ANS) return ;   // priority can prune through 
    IF (PA> n-|| Pb> n-) return ;
     IF (PA == Pb + 2 * n-) {      // this can not take precedence over ... not understand why ... 
        ANS =max(ans, tsum); 
        return;
    }
    
    int p=pa+pb+1;
    ll ta=tsum, tb=tsum; 
    for(int i=1; i<=pa; i++)
        ta-=Map[A[i]][p];
    A[pa+1]=p;
    dfs(pa+1, pb, ta);
    for(int i=1; i<=pb; i++)
        tb-=Map[B[i]][p];
    B[pb+1]=p;
    dfs(pa, pb+1, tb);        
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i=1; i<=2*n; i++)
        for(int j=1; j<=2*n; j++)
        {
            cin>>Map[i][j]; 
            sum+=Map[i][j];
        }
    sum/=2; 
    dfs(0, 0, sum); 
    cout<<ans<<endl;
    return 0;    
} 
View Code

 

Guess you like

Origin www.cnblogs.com/Yokel062/p/11222355.html