# Bzoj plan 201:bzoj1820: [jsoi2010]express Service Courier Services

Source: Internet
Author: User

http://www.lydsy.com/JudgeOnline/problem.php?id=1820

It's easy to think of Dp[i][a][b][c] to the first pickup location, the minimum fuel consumption of three drivers at the A,b,c pickup location

Enumerating the I-I pickup locations is there a driver coming over?

n*m*m*m= 8e9 Tle&&mle

One-dimensional compression, to the first I pickup location, there must be a driver at the first pickup location

N*m*m=4e7 MLE

Rolling array rolling out the first dimension

`#include <cstdio>#include<cstring>#include<iostream>using namespacestd;#defineM 201intDis[m][m];intdp[2][m][m];voidReadint&x) {x=0;CharC=GetChar ();  while(!isdigit (c)) c=GetChar ();  while(IsDigit (c)) {x=x*Ten+c-'0'; C=GetChar ();}}intMain () {intm;    Read (m);  for(intI=1; i<=m;++i) for(intj=1; j<=m;++j) Read (Dis[i][j]); intX,last;    Read (last); memset (dp[0], the,sizeof(dp[0])); intinf=dp[0][0][0]; dp[0][2][3]=dis[1][last]; dp[0][1][3]=dis[2][last]; dp[0][1][2]=dis[3][last]; intu=1, v=0;  while(SCANF ("%d", &x)! =EOF)        {swap (U,V); memset (Dp[v], the,sizeof(Dp[v]));  for(intI=1; i<=m;++i) for(intj=i;j<=m;++j)if(dp[u][i][j]!=inf) {Dp[v][i][j]=min (dp[v][i][j],dp[u][i][j]+dis[last][x]); Dp[v][min (last,j)][max (last,j)]=min (Dp[v][min (last,j)][max (last,j)],dp[u][i][j]+dis[i][x]); Dp[v][min (last,i)][max (last,i)]=min (Dp[v][min (last,i)][max (last,i)],dp[u][i][j]+dis[j][x]); } Last=x; }    intans=inf;  for(intI=1; i<=m;++i) for(intj=i;j<=m;++j) Ans=min (ans,dp[v][i][j]); cout<<ans;}`

1820: [jsoi2010]express service delivery time limit:10 Sec Memory limit:64 MB
submit:1118 solved:482
[Submit] [Status] [Discuss] description"Gallop" After the establishment of the express company, has been with many small and medium enterprises in the city signed mail delivery service contract. Since some of the companies are in the same building, the location of the "flying" Company's pickup (the pickup point) is at most only m (1, 2, ..., m), so "dash" has procured only three vehicles and hired three drivers each morning, departing from "1","2" and "3", respectively, from the pickup location. In relation to the customer's service contract, it is expressly contracted that the "dash" must send the person to the company (location) the day after the customer has sent the requested email. In order to be able to serve customers more efficiently and save time, the company has set up a receiving service registration website, if the customer has to send the mail, must be on the day before the receipt of the online registration. In order to save oil, "Gallop" uses the evening to arrange three drivers the next day's pickup route. The order of each driver to all parts of the registration shall be in accordance with the order of the companies to register online and must be able to complete all the receiving services of the day with the most fuel-saving conditions. Therefore, each driver may need to repeat to the same location at different times, or different drivers may need to go to the same location at different points in time to receive the item. As shown in Example II below (the location of the receiving company is: 4 2 4 1 5 4 3 2 1), although the driver was "1" at the pickup location at the beginning of 11, he could not first take the fourth registered company (location "1") mail to the first, second, or third registered pickup location (location "4","2" , "4") pickup. However, if the first three registered receiving services are handled by drivers 2 or 3, the driver 1 can collect the fourth registered mail at the location "1" and then go to the place where they are registered. In addition, in some cases, it is not necessary for each car to receive the goods, that is, the best way to pick up is probably just one or two vehicles to pick up the goods. Please write a program to help "Dash" calculates the minimum total fuel consumption per day according to the order of appointment to each receiving location. The first line of the input file has an integer m (3 < = m < = 200), representing the number of places the "flying" Company received, representing each location with an integer designator between 1 and M. The next M-line (2nd to m+1), each line has m integers, representing a matrix d. The J integer of line i + 1 is D (i, J), D (I, j), which represents the fuel consumption required by the driver from the pickup point I to the point J of the pickup. Finally, there are a number of lines, the number of numbers in sequence is the previous day online registration requirements of the company location code, there will be a maximum of 1000 receiving requests. Any two adjacent integers in the input file are separated by a blank space. D (i,j) <=maxint Note: The oil matrix D satisfies the triangular inequalities, that is to say D (i, j) < = d (i, K) + D (k,j), 1 < = I, J, k < = M. As a result, each vehicle must travel directly to the next pickup location without having to take a detour to another location before arriving at the next pickup location. Output outputs an integer representing the minimum total fuel consumption required for the pickup. Sample Input4
0 5 0 6
6 0 5 6
1 6 0 6
1 1 1 0
1 1 1 1 4 4 2 2 2 3

Sample Output6

Sample Description: The driver to each request pickup location is 1 1 1 1 3 3 2 2 2 1, so the driver 1 only need to move from the point 1 to the location 3, the driver 2 to stay at the location 2, driver 3 from the starting point 3 moved to location 4.
HINT

Bzoj plan 201:bzoj1820: [jsoi2010]express Service Courier Services

Related Keywords:
Related Article

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.