Link to the question: Ultraviolet A 1399-puzzle
Given K and N, there are k different characters. N are prohibited strings. Find the longest string so that the string does not contain any prohibited strings as substrings. If a loop exists or cannot be formed, no is output.
Solution: Establish an AC automatic machine and then perform DP on the AC automatic machine. The end nodes of all words are forbidden points.
#include
Ultraviolet A 534-Frogger
Question Link
Given some points, a path is required to jump from the first point to the second point, and the maximum distance on the path is the smallest.
Idea: Use the Kruskal algorithm to add the edge of the smallest weight value each time to determine whether the edge can be connected to two points. If yes, the current weight is that the answer complexity is O (n ^ 2log (n ))
But in fact, I can use Floyd to create O (N ^
Ultraviolet A 11573-ocean currents
Question Link
Given a sea surface, the number represents the current direction, and does not charge energy along the current. The reverse current consumes 1 point of energy. Each time you ask a start point, an endpoint is given, minimum energy consumption from the start point to the end point
Train of Thought: broad search, the queue uses a priority queue, each time the lowest energy point out for status transfer
Cod
Ultraviolet A 10457-magic car
Question Link
M Road, each road must maintain speed v. Now there is a car with startup and end energy as A, B, the energy consumed during the process is the maximum speed through the path minus the minimum speed. Now, each cycle is given the start end point and the minimum energy consumption is
Train of Thought: Minimize the bottleneck and use Kruskal
Code:
#include
Ultraviolet
Link to the question: Ultraviolet A 11732-strcmp () anyone?
N strings are given, and then compared to each other.
Solution: Create a dictionary tree and record the number of strings containing the node based on the nature of the dictionary tree. Because the number of nodes is large, you can use the left Child's Right brother method to create a dictionary tree.
#include
Ultraviolet A 11732-strcmp () anyone
Ultraviolet A 1364-Knights of the Round Table
Question Link
Q: There are n Round Table knights who know that some of them hate each other. Now we want to hold a round-table meeting. Each time we have at least three people, we must have an odd number of people, and those who hate each other cannot be adjacent, ask how many server guard cannot participate at a time.
Train of Thought: Set the adjacent edge of each server guard and perform the dual-connec
Link to the question: Ultraviolet A 11557-code theft
Given n texts, each text has a text name. Now a text is given, finding the maximum number of consecutive rows in the given text and N texts, and outputting the text name, note that when the value is 0, no other text names are output.
Solution: map each string into a hash value, then enumerate the suffixes of matched text, create a mismatch array for KMP matching, and record the maximum value of matc
Link to the question: Ultraviolet A 1462-fuzzy Google suggest
Simulate a fuzzy search by Google. given to a string set, there are then n searches. Each time there is an integer x and a string, which indicates that the string can be modified X times, this includes adding, modifying, and deleting a character. The modified character may be the prefix of the number of strings in the character set.
Solution: first, create a dictionary tree. For each search
Subject address: Ultraviolet A 11134
This is because the rows and columns are irrelevant and have no impact on each other. Therefore, you can separate rows or columns for calculation. This is equivalent to converting to selecting n different integers in the period [1, N], so that the I-th integer is within the Closed range [Li, Ri. This is a greedy problem. However, note that you cannot sort by left endpoint first, then by right endpoint, and then try
Ultraviolet A 11256-repetitive multiple
Question Link
Find a minimum value that is equal to a multiple of N and a repeating number (according to the definition in the question)
Train of Thought: if it is a repeated number, the form must be a number of the corresponding digits in the form of 100010001, so you can enumerate such numbers, and N to take GCD, if the number of remaining digits is smaller than the number of digits, multiply the number to mak
Link: Ultraviolet A 1385-billing tables
Given n phone prefixes, each prefix is the prefix of a region. Now a new phone bill is generated, that is, for each phone number, the old phone bill is traversed from the front to the back, if the prefix matches, the phone number corresponds to the current zone number, and the new phone number must be as small as possible.
Solution: Use DFS to create a dictionary tree. All vertices in the interval range correspo
Ultraviolet A 1521-GCD guessing game
Question Link
Assume that the number X is between 1 and N. Now, you can guess the number a, tell the answer to gcd (X, A), and guess the number several times in the worst case.
Idea: In terms of prime numbers, you can guess the numbers composed of these prime numbers by guessing the product of a group of prime numbers. The answer is the number of groups, this problem is how to minimize the number of groups by group
Link: Ultraviolet A 11922-permutation Transformer
Given a sequence, each operation extracts the range ~ B. Flip and put it at the end, and then output the sequence.
Solution: stretch the tree. Set a flip for each node to indicate whether it is flipped or not. Each time a is rotated to the root, split, then flip B to the root, split, and put the mid to the end.
#include
Ultraviolet A 11922-permutation Trans
Ultraviolet A 10909-lucky number
Question Link
Question: Can a number be constructed by two lucky num numbers?
Idea: we can use the tree array to find the first K to construct the lucky num sequence. Then, each time we look for N, we can start from n/2.
Code:
#include
Ultraviolet A 10909-lucky number (tree array)
Link to the question: Ultraviolet A 1232-Skyline
It is the maximum value of N modifications and maintenance. If the maximum value of a position is modified, the overwrite value is + 1.
Solution: Modify the interval of the Line Segment tree. After each modification, return the length of the modified interval.
#include
Ultraviolet A 1232-Skyline (line segment tree)
Ultraviolet A 1471-defense lines
Question Link
For a given sequence, it is required to delete a continuous subsequence. The obtained sequence has the longest continuous increasing sequence and the maximum length of the continuous increasing sequence is output.
Train of Thought: first scan left and right, record the maximum length of each position to the left and to the right, and then scan again from left to right, open an array min to record the sequ
Link to the question: Ultraviolet A 10588-queuing at the doctors
The company arranges employees to perform health checks. A total of N people and M projects, given the time each employee arrives at the hospital, as well as the items and sequence for the health check, each project inspection of one person requires a unit of time. Doctors in each project perform health checks first to employees, and at the same time, employees who receive health checks
Ultraviolet A 11557-code theft
Question Link
Give some code text, and then find the existing text and the previous Code text given an existing text, repeat the text with the most consecutive lines
Train of Thought: Hash each line into a value, calculate the maximum matching value for each text, enumerate the suffix, and then use KMP to find it.
Code:
#include
Ultraviolet A 11557-code theft (KMP + hash)
Link to the question: Ultraviolet A 12130-Summits
Given an n? M graph, each position has a value. Given D, if a node value is G as the starting point, it cannot be moved to a position where the value is less than or equal to G? D node. Now we need to find all the peak points in the entire graph. The definition of the peak point is that it cannot be moved to a location that is larger than its own node value.
Solution: Sort each location by weight and m
Ultraviolet A 11020-Efficient Solutions
Question Link
Each person has two attribute values (x, y). For each person (x, y), when there is another person (x', y '), if their property values meet the requirements of X'
Train of Thought: because each person loses his or her advantage and cannot gain another advantage, he or she can delete these points. In this way, he or she can use a Multiset to maintain the point set and add one point each time, use lo
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.