Code: Https://github.com/jinhang/2016_Huawei_SoftWareMatch
Preface
The problem originates from the routing calculation in the "Future Network" service distribution. The problem of calculation is the basic algorithm problem, in the graph theory, network, traffic and other aspects have a wide range of research and application, there are some classic algorithms, such as the shortest-path in the breadth of first search, Dijkstra algorithm. The better algorithm implementation of network routing problem is of great value for the efficient configuration of network resources.
This competition is divided into preliminary , semi -finals and the final three major stages, currently the final/semi -finals stage.
Final/Semi-finals title Description
1 Problem Definition
Given a weighted graph g= (v,e), V is a vertex set, E is a set of edges, and each has a weighted edge. For a given vertex s, T, and a subset of V ' and V ', looking for the two non-circular path p ' and P ', from S to T, so that P ' passes through all the vertices of V ', and P ' passes all the vertices in V ' (the order of the vertices in P ' through V ' and P ' through V ') The order of the vertices is not required).
If there is no such two path, then the output is no solution, the shorter the program running time, it is considered as the result is better, if there is such a two-way path, the output of the two path, the following priority from high to low evaluation results:
1, the path P ' and P ' coincident with the number of forward side of the less, it is considered as the result of the better;
2, in the case of two paths coincident with the number of forward edges, the less the sum of two path weights, the better the result;
3, in the same situation as the above two indicators, the shorter the program running time, it is considered the result is better.
Description:
1) All the weights in the graph are integers in [1,100];
2) The starting point of any one having an edge is not equal to the end point;
3) connecting vertex A to vertex B may have more than one edge, the weight may be the same, or it may be different;
4) There are no more than 2000 vertices of the graph, and each vertex-out (the number of forward edges that start with that point) does not exceed 20;
5) The number of elements in V ' and V ' is no more than 100, the intersection is empty and does not contain the starting vertex s and the terminating vertex t;
6) The non-circular path from S to T p means that p is a forward connected path from S to T consisting of a series of forward edges, and does not allow repetition to pass through any vertex;
7) The weight of the path refers to the sum of all the weighted weights of all the forward edges that make up the path (the weights of the repeating edges should be computed once in each of the two paths).
2 input and output
input file Format
A two. csv file (CSV is a comma-delimited text file) gives the input data, one for the graph (G), and one for the path information to be computed (s,t,v ', V '). Each line of the file ends with a newline character (ASCII ' \ n ', which is 0x0a).
1) in the figure data, each line contains the following information:
Linkid,sourceid,destinationid,cost
Where LinkId is the index of the forward edge, SourceID is the index of the starting vertex of the forward edge, and DestinationId is the index of the terminating vertex of the forward edge, and the cost is the weight of the forward edge. The index of the vertex and the forward edge are numbered starting at 0 (not necessarily contiguous, but the use case guarantees that the index is not duplicated), the vertex index range is in [0,2000], and there is a forward edge index range in [0,40000].
2) in the path information, there is only one row of the following data:
Demandid,sourceid,destinationid,includingset
Wherein, demandid inside the first behavior 1, the second behavior 2, represents the path index, 1 means P ', 2 means P ', SourceID is the index of the starting vertex s, DestinationId is the index of the terminating vertex T, Includingset represents the vertex set that must pass through V ' or V ', where different vertex indexes are used between the "| ", enter Na here if the path does not have to be required by the vertex.
output File Format
The output file is also a. csv file.
1) If the test case exists to meet the requirements of the Forward path P ' and P ', then output two lines of information, the first row by the "P" through the forward side of the order, sequentially output a forward edge index, between the index with "| The second line outputs a forward-edged index in order of the "P", followed by a "| Segmentation
2) If the test case does not exist at the same time, there are two forward paths that meet the requirements P ' and P ', output only one line of information: NA;
3) Each line is allowed to output up to one forward path only, ending with a newline character 0x0a.
3 scoring mechanism for individual use cases
ranking mechanism for solving use cases
rank the contestants ' results by the following process:
Step1: for the results of the submission, the legality test (see the title description);
STEP2: program run time must not exceed 10s;
If the above results are not satisfied, the use case score is 0;
Step3: The number of forward edges coincident with the path P ' and P ' (regardless of weight), the better the ranking;
Step4: in the case where the path P ' and P ' coincide with the number of forward edges, the weights and weights of P ' and P ' are calculated, the lower the weight, the better the ranking;
Step5: in the same situation as the above two indicators, the program run time to refine the ranking, the shorter the time, the better ranked.
ranking mechanism for non-solution use cases
rank the contestants ' results by the following process:
Step1: for the result of the submission, verify whether the use case is not solved, if it is not recognized or the program run time is over 10s, the use case score is 0;
STEP2: Use the program's running time to rank, the shorter the time, the better ranked.
the scoring criteria for a single use case are as follows:
based on the ranking of the above ranking process, the standard score is used (the number of the first submitter is 100 points).
If the average person does not get the right result, then all will be divided into 0.
4 website System enigmatic grading mechanism
semi-final phase of the official website open to receive the semi-final program submitted, the system platform will use N test Case Online award, the contestant for each test case will get a percentile score, using arithmetic average divided into the contestant's final score, and displayed in the regional rematch leaderboard.
Special note: The final stage of the online grading questions and rankings for participants only for reference, not included in the ultimate semi-finals results.
5 Simple use case description
in the graph shown, we get the following graph information:
0,0,1,1
1,1,2,1
2,2,3,1
3,1,4,1
4,4,3,1
5,0,5,1
6,5,2,1
If you need to find the path from 0 to 3 p ' and P ', and P ' must pass vertex 1,p ' must go through vertex 2, the corresponding path information file contents are:
1,0,3,1
2,0,3,2
For this use case, you can find the following two groups of solutions:
0|1|2
5|6|2
And
0|3|4
5|6|2
Because the number of coincident edges of the first set of two paths is 1, the number of coincident edges of the second set of two paths is 0. So the optimal solution should be 0|3|4,5|6|2 at this time.
6 rematch Format Description
the regional promotion of the second round team for 32-36 teams, semi-finals using the form of a regional field competition, divided into three small stages:
1, Qualifying: Regional field rematch on the day, the region will be through an official use case to enter the third party to submit the process of scoring and sorting, the ranks of the top 8 teams will be the next phase of the Group 8 group seeded, the rest of the team by drawing the group.
2, sub-race: The region is divided into 8 groups, each team using a single cycle of competition, through the points (win 3 points per game, flat 1 points, minus 0 points) for the group sort, ranked the top 2 team to enter the next phase of the elimination of the qualifying race.
3, the elimination of the race: the group of qualified team composed of 16, divided into the upper and lower half of the 22 battle phase out of the race, divided into the "1/8 finals → 1/4 finals → Semi -finals → final", finally decide the region 4 strong into the national finals.
Two-team PVP Rule description:
1, the second-round sub-tournament and the elimination of the race are used in the form of two teams, each match 9 innings 5 wins. (Group 3 points, negative accumulation of 0 points, flat each product 1 points, the final ranking of points in the same case, qualifying results by the former winner; the knockout of a tie, the official use of the case "overtime" to decide the outcome);
2, the two sides (such as red, blue side) each need to provide 2 self-designed use cases, the official 5 use cases, a total of 9 use cases of 9 innings to fight, the use cases issued in the order: Red Fang 1→ Blue square 1→ Red 2→ Blue 2→ official 1→ official 2→ The official 3→ official 4→ official 5;
3, each game, such as due to the use of their own cases caused by their own calculation, then the other party automatically wins, the rest of the "single use case scoring mechanism" to determine the outcome.
7 General final format Description
each region of the first four 32 teams to qualify for the finals, the final contest in the form of live competitions, divided into three small stages:
1, qualifying: The final day, the organizing committee will pass the two official match use cases to enter the finals team submitted procedures for scoring and sorting. Each team ranked according to the ranking of qualifying scores, 1-8 were designated as seeded (first), 9-16 for the second, 17-24 for the third, and 25-32 for the fourth gear. Qualifying rankings are only for group lottery use, does not affect the final ranking of the team;
2, sub-race: The National 32 is divided into 8 groups, the group process using lots, seeded draw to a1-h1 position, the second team draw to A2-H2 position, the third team draw to A3-h3 position, the fourth team draw to A4-h4 position, forming group group. Each team uses a single-cycle PvP contest, through the points (win 3 points per game, the level of 1 points, minus 0 points) for the group sort, ranked the first 2 teams of the team into the next phase of the elimination of the qualifying race. In the case of the same points, will be based on the "net win-win relationship advantage-upload time early" priority ranking;
3, the elimination of the race: the group of qualified team composed of 16, divided into the upper and lower half of the 22 battle phase-out race, divided into the "1/8 finals → 1/4 finals → Semi -finals → final", the final national championship.
Two-team PVP Rule description:
1, the finals of the tournament and the elimination of the race are used in the form of two teams, each battle 9 innings 5 wins. (a tie is allowed in the tournament and a tie is drawn in the playoffs, and the "Upload time early" team wins);
2, the two sides (such as red, blue side) each need to provide 2 self-designed use cases, the official 5 use cases, a total of 9 use cases of 9 innings to fight, the use cases issued in the order: Red Fang 1→ Blue square 1→ Red 2→ Blue 2→ official 1→ official 2→ The official 3→ official 4→ official 5;
3, each game, such as because of the use of their own cases caused by their own calculation, then the other party automatically wins. Official provision for example, neither party calculates the correct path, and neither of them can be divided. The rest is judged by the "single use case scoring mechanism".
8 Description of the teams ' self-generated PVP test Cases
by the official in the semi-finals stage to provide a number of complete use cases as the material for the player to generate use cases, the player can edit the use cases (such as the deletion of vertices, a forward edge, must pass vertices, modify the starting end vertex, etc. The official will open the use case design tool through the contest website to the competition team entering the rematch.
9 Finals/rematch considerations
1, the core algorithm prohibits the use of third-party code;
2, if the reference to a paper or third-party code, you must provide a source description in the Readme file;
3, for all use cases must use the same algorithm and the same set of code implementation.
Description of the preliminary contest title
1 Problem Definition
given a weighted graph g= (v,e), V is a vertex set, E is a set of edges, and each has a weighted edge. For a given vertex s, T, and a subset of V ', look for the non-ring-to-path p from S to T, so that p passes through all the vertices in V ' (the order of the nodes in V ' is not required).
If there is no such a forward path p, then the output is no solution, the shorter the program running time, it is considered as the result is better; if there is such a direction path p, then the resulting path, the lower the weight of the path, the better the result, in the same way as the output path weight, the shorter the program, the better the result
Description:
1) All the weights in the graph are integers in [1,20];
2) The starting point of any one having an edge is not equal to the end point;
3) connecting vertex A to vertex B may have more than one edge, the weight may be the same, or it may be different;
4) There are no more than 600 vertices of the graph, and each vertex-out (the number of forward edges that start with that point) does not exceed 8;
5) The number of elements in V ' is not more than 50;
6) The non-ring direction from S to t p means that p is a forward connected path consisting of a series of forward edges from S to T, and it is not allowed to repeat through any node;
7) The weight of the path refers to the sum of all the weighted weights of all the forward edges that make up the path.
2 input and output
input file Format
The input data is given in two. csv files (CSV is a comma-delimited text file), one for the graph (G), and one for the path information (S,T,V ') that needs to be computed. Each line of the file ends with a newline character (ASCII ' \ n ', which is 0x0a).
1) in the figure data, each line contains the following information:
Linkid,sourceid,destinationid,cost
Where LinkID is the index of the forward edge, SourceID is the index of the starting vertex of the forward edge, and DestinationId is the index of the terminating vertex of the forward edge, and the cost is the weight of the forward edge. The index of the vertex and the forward edge is numbered starting at 0 (not necessarily contiguous, but the use case guarantees that the index is not duplicated).
2) in the path information, there is only one row of the following data:
Sourceid,destinationid,includingset
Where SourceID is the starting point of the path, DestinationId is the end of the path, and Includingset represents the vertex set V ' that must pass through, where a ' | ' is used between different vertex indexes Segmentation.
output File Format
The output file is also a. csv file.
1) If the test case exists to meet the requirements of the Forward path P, then press p through the forward edge order, the output has a forward Edge index, the index between the ' | ' Segmentation
2) If the test case does not exist to meet the requirements of the Forward path p, then output two characters na;
3) Only one forward path is allowed to be output.
3 scoring mechanism for individual use cases
ranking mechanism for solving use cases
rank the contestants ' results by the following process:
Step1: for the results of the submission, the legality test (see the title description);
STEP2: program run time must not exceed 10s;
If the above results are not satisfied, the use case score is 0;
Step3: Calculate the weight of the submitted path, the smaller the weight, the better ranked;
Step4: in the same weight results, with the program run time ranking, the shorter the time, the better ranked.
ranking mechanism for non-solution use cases
rank the contestants ' results by the following process:
Step1: for the result of the submission, verify whether the use case is not solved, if it is not recognized or the algorithm run time is over 10s, the use case score is 0;
STEP2: Use the program's running time to rank, the shorter the time, the better ranked.
the scoring criteria for a single use case are as follows:
based on the ranking of the above ranking process, the standard score is used (the number of the first submitter is 100 points).
If the average person does not get the right result, then all will be divided into 0.
4 final scoring mechanism
The platform will use N test case, the n test cases are divided into primary, intermediate, advanced three levels, contestants for each test case will get a percentile score, the use of weighted average (primary weight of 0.2, intermediate weight of 0.3, advanced weight 0.5) as the final score of the contestant.
Special note: In the early stage of the game, the platform only released the primary, intermediate test cases, so when the full 50 points, in the late game, will release the advanced test Cases (specific release time will be notified on the site notice), at this time out of 100 points, please contestants attention.
5 Simple use case description
in the graph shown, we get the following graph information:
0,0,1,1
1,0,2,2
2,0,3,1
3,2,1,3
4,3,1,1
5,2,3,1
6,3,2,1
If you need to find a path from 0 to 1, and must go through vertices 2 and 3, we will get the following path information:
0,1,2|3
for this use case, you can find the following two feasible paths:
1|5|4
2|6|3
Since the first path has a weight of 4 and the second path has a weight of 5, the optimal solution should be 1|5|4 at this time.
Operating Environment
Cpu:intel Xeon CPU e5-2690 V2 @ 3.00GHz
Memory: 2G
Kernel: Single Core
Compiler: GCC 4.8.4;java 1.7.0_95;
Operating system: Linux Ubuntu 14.04.3 LTS 64-bit, kernel version, Linux version 3.13.0-24-gineric
SDK: For the convenience of the players to do the problem, provide C + + (compatible with C) and Java SDK Package for reference (see the game download package), detailed description of the information, see the SDK directory readme.txt.
Huawei Software Elite Challenge 2016