P2196 dig mines

---------------------------

Let me tell you, this is the road of yellow false questions, the difficulty was almost universal, too much water

---------------------------

Proposed nothing to say, he wants to search

---------------------------

Topic links: Miku

--------------------------

1  / * 
2  This is a false channel yellow question 
 . 3  
. 4  * / 
. 5  
. 6  
. 7  
. 8  
. 9 #include <the iostream>
 10 #include <algorithm>
 . 11 #include <CString> 
 12 is #include <Queue>
 13 is #include <cstdio>
 14  
15  the using  namespace STD;
 16  int now [ 21 is ]; // current order 
. 17  int ANS [ 21 is ]; // answer sequence 
18 is  int CNT; // answer 
. 19  int VIS [21 ]; // back a recording 
20 is  int TU [ 21 ] [ 21 ]; // Unicom 
21  int V [ 21 ]; // Value 
22 is  int n-;
 23 is  int X;
 24  void DFS ( int P, int K, int CNTT ) {
 25      IF (VIS [P])
 26 is      return ;
 27      VIS [P] = . 1 ;
 28      now [K] = P;
 29      for ( int= I . 1 ; I <= n-; ++ I)
 30      {
 31 is          IF ! (I && P TU = [P] [I] && VIS [I])! // is not repeated digging + = Unicom not dig dug 
32          {
 33 is              DFS (I, K + . 1 , CNTT + V [I]); // recursive 
34 is              VIS [I] = 0 ;
 35          }
 36      }
 37 [      IF (CNTT> CNT)
 38 is      {
 39          CNT = CNTT; // record 
40          for ( int I = . 1 ; I <= n-; ++ I)
 41 is         {
 42 is              ANS [I] = now [I]; // update path 
43 is          }
 44 is      }
 45      now [K] = 0 ; // this also additional processing 
46 is  }
 47  
48  int main () {
 49      CIN >> n-;
 50      for ( int I = . 1 ; I <= n-; ++ I)
 51 is          {
 52 is              CIN >> V [I];
 53 is          }
 54 is      for ( int I = . 1 ; I <= n-; ++ I)
 55     {
56         for(int j=i+1;j<=n;++j){
57         cin>>x;
58         if(x)
59         tu[i][j]=1;
60         }
61     }
62     for(int i=1;i<=n;++i)
63     {
64         dfs(i,1,v[i]);
65         vis[i]=0;
66     }
67     for(int i=1;i<=n;++i)
68     {
69         if(!ans[i])
70         break;
71         else
72         cout<<ans[i]<<" ";
73     }
74     cout<<endl<<cnt;
75     return 0;
76 }
AC

----------------------------

Have a good day.

Guess you like

Origin www.cnblogs.com/For-Miku/p/11025111.html