Recently completed the first version of nyist OJ (http://acm.nyist.net), sort out. As some questions have been completed last year, they have not been done, so they do not include all questions from 1. For more information, see solution report V1.0 of Nanyang Institute of Technology OJ 1st. This article involves the source code http://code.google.com/p/algorithm-mdyang//nyist
What to doFor details about the following, refer to source code 3: area is calculated using a triangle. the center of gravity is calculated based on the center of gravity of each triangle and area weighting. 5: brute force matching, or string. h's find () function (or STD: String: Find (), or convert a binary string to an integer for comparison, or any other
String Matching Algorithm (KMP, Rabin-Karp)10: DP: records the length of the current line when each coordinate point is used as the end point of the line. The initial coordinate point length is set to 1. The State Conversion Equation f (x, y) = max {f (x, y), {(x, y) adjacent contact length value + 1} higher than (x, y) terrain, iteration to convergence, traversal, maximum length of all output points. You can use a rolling array to save space: 20: BFS (DFS needs to pay attention to pruning to avoid TLE) 21: BFS (with the water capacity of three cups as the State, with a single pouring as the state conversion) 23: sum up n % (m + 1 )? "Win": "lose" 25: The question seems to be faulty. If following 10 is considered, an error is reported. If you do not consider it, 26: The scale is not large. You can create tables (for example, the scale is too large.
Rabin-Miller10) 30: enumerate the last lake to arrive. For each case, deduct all the journey time and select the most fish lake fishing in the remaining time. 32: recursive 35: typical data structure question 37: minimum addition number = strlen (S)-LCS (S, reverse (s) 38: Minimum Spanning Tree, Prim/kruskal42: determination of the existence of undirected Euler's path
43: recursion (the beauty of programming 1.16 "24-point Games ")
44: continuous addition starts from the first variable. The maximum substring sum is updated after each addition. If the current substring is negative, the calculation starts from the next element.45: Big integer multiplication 46: log (n) multiplication: WHEN n is an odd number, a ^ n = A * a ^ (n-1 ), even number a ^ n = (a ^ (n/2) ^ 247: greedy choice, see the http://www.cnblogs.com/drizzlecrj/archive/2007/10/20/931011.html
49: 0-1 backpack problem, DP Solution52: Find the loop. Note that N can be 99999 at the maximum. So int32 indicates that N ^ 2 is not enough (4e9 at the maximum). The test program that requires int64 can only find 0-word loops, at the beginning, I wrote a wa statement that can be used to find a 6-character loop. Here is an example of a 6-character loop (n = 2, K = 2 ): 2 4 8 16 32 64 28 56 12 24 96 92 84 68 36 72 44 88 76 52 4 ^ <-------------------------- 20 -------------------------- | but if you are looking for a 0-word loop, because it will never return to 2, we should output-1. A 0-character loop is much simpler. You can query 10 ^ K times at most (because the last K-bit value can be 10 ^ K at most, if there is a 0-character loop, the longest cycle is N, N ^ 2... N ^ K, that is, k) 55: Merge the smallest two heaps at a time 59: first check whether the input is unsolvable, fix the first person in the first position one way to the left (or one way to the right, it doesn't matter) arrange seats, calculate the difference I between each person and the original position in the new position after the arrangement, and count the number of occurrences of each I value. The maximum number of occurrences is M, then the ranking scheme needs to move c = N-m people, calculate the C value of all the ranking schemes, and output the minimum C value.
61: Multidimensional DP
Http://blog.csdn.net/epiker/article/details/7482875 Network Flow
Http://acm.nyist.net/JudgeOnline/articles? P = 48
66: K = x * Y/(Y + x) and X, Y, K are all integers, so that Y <= x <= K * (k + 1)67: vector formula or Helen formula 71: tail head (first tail and then head) greedy 75: leap year judgment
76: recursive formula F (1) = 0, F (2) = 1, F (3) = 2, F (n) = f (n-1) + f (n-2)
78: Point Set convex hull
79: DP, the longest monotonic decreasing subsequence. In fact, I think there is a problem with this question. Based on the question, the longest monotonic non-incrementing subsequence should be obtained, but wa should be performed according to this requirement, and the AC will be changed
80: TBD81: DP. Line-bit compression indicates the terrain and deployment scheme. Bit operations determine whether the deployment scheme conflicts with the condition. You can use a rolling array to save space 82: dfs83: Line Segment intersection identification. Possible line segments: from all possible edge points to the points where the treasure is located. The Edge Points are any point located in the middle of the two adjacent wall endpoints on the labyrinth boundary (you can directly take the midpoint) 84: depends on 1 .. number of factors 5 in N, so it is N/5 (5, 10, 15, 20, 25... + N/25 (75,100,125... + N/2nd (125... + N/5 ^ I (5 ^ I, 2*5 ^ I, 3*5 ^ I... (I), where I is the maximum value for making N> = 5 ^ I
86: Hash statistics
87: Multidimensional DP88: F (n + 1) = 2f (n) + 1, S (n) = 2 ^ n-1
89: recursion. recursive decomposition is considered from the largest dish.90: recursive decomposition: f (x) = 1 + H (x-1, 1) + H (X-2, 2) +... + h (x-X/2, X/2), where H (X, Y) is the number of decomposition solutions for X, all of which meet the following conditions: n> = y. recursive expansion of h (x, y): h (x, y) = 1 + h (x-y, Y) + h (x-(Y + 1 ), Y + 1) +... + h (x-X/2, X/2) 91: n <1000000, we only need to consider 9! = 362880, if 1 !.. 9! Each occupies a binary digit, then 0 ~ 2 ^ 9-1 indicates all combinations (512 in total). If the results are left blank, they are saved to the table. The result of the query is 92: The result is scanned along the edge. If the values are not 0, the BFS is set to 0. One way to compare tricky is to add a circle of 1 at the periphery and then start from (0, 0) bfs93: Simulation
94: Simulate. Keep all cigarette butts until all cigarette butts are left <K: Output smoke count 95: Hash count 99: view the input as a directed graph. The vertex is a letter and the edge is a word, the question of word concatenation is converted from the first letter to the last letter to the question of searching for the Euler path in the directed graph. Locate the Tle directly by DFS, and identify by connectivity> Euler's path/loop existence> Search for the minimum alphabetic order of DFS. the Euler's path can be AC. inspiration: for questions that do not necessarily have a solution, you can search and pruning by determining the existence of the solution. If the given input of the ontology does not have a solution, all the possibilities of DFS must be used to determine that the solution does not exist. Therefore, tle100: bit-by-bit statistics