Hdu 3001 (solid-pressure dp + tri-hexadecimal)

Source: Internet
Author: User

Hdu 3001 (solid-pressure dp + tri-hexadecimal)

Whether it is a few hexadecimal notation, it uses a logical concept. (The last hexadecimal notation was used to convert multi-dimensional data) the core idea is TSP. The Preprocessing here is clever, and the modulo vis [] [] on each bit in each state is calculated.

TSP: the optimal solution ending with j in the I state of dp [I] [j. Both types of transfer are supported: I am for everyone and everyone is for me.


# Include
 
  
# Include
  
   
# Include
   
    
# Include # define maxn 60000 # define inf 0x3f3f3f3fconst double eps = 1e-8; using namespace std; int dp [maxn] [12]; int maps [13] [12]; int vis [maxn] [12]; int state [12]; int n, m; void init () {state [0] = 1; for (int I = 1; I <11; I ++) state [I] = state [I-1] * 3; for (int I = 0; I <= state [10]; I ++) {int x = I; for (int j = 0; j <10; j ++) vis [I] [j] = x % 3, x/= 3 ;}} int main () {// freopen ("in.txt", "r", stdin); while (~ Scanf ("% d", & n, & m) {init (); memset (maps, 0x3f, sizeof (maps); for (int I = 0; I
    
     


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.