Ultraviolet A 1428-Ping pong (tree array)
Link to the question: Ultraviolet A 1428-Ping pong
There are n table tennis fans living in a street and they often organize competitions. Each person has a different ability value. Each game requires three people. The referee must live between two players and the ability value must also be between players, ask how many matches can be held at most.
Solution: Pre-proc
Ultraviolet A 11235-Frequent values (RMQ)
Link to the question: Ultraviolet A 11235-Frequent values
Given a non-descending integer array, it is required to calculate some queries (I, j), answer ai, ai + 1 ,..., The maximum number of occurrences in aj.
Solution: Because the sequence is non-descending, the same numbers must be tied together, so we use the o (n) method to process the intervals of the same numb
// Ultraviolet (a) problem 122-trees on the level // verdict: accepted // submission date: 2011-12-25 // ultraviolet (a) Run Time: 0.008 S // All Rights Reserved (c) 2011, Qiu. Metaphysis # Yeah dot net // [solution] // This question can be attributed to a data structure problem. The step is to create a tree structure and check whether it is complete. If it is complete, the nodes are output in depth. # Incl
Ultraviolet A 10941-words Adjustment Question Link Question: Given two strings, given some word sets, ask if you can add some words after each of the two words to make the two words the same. Ask how many times to add the word, the word must come from the word set Train of Thought: extensive search, recording characters in different States between two strings, using set and string to mess up .. You can. Code: # Include
Label: style HTTP color OS Io for Ar CTI Ultraviolet A 11748-rigging elections Question Link N-person election: Give the priority of M-person voters for everyone. Now you want to win for the C-person and ask if you can Idea: If a can win B for two people, build a side of a-> B. Then the question is, can c be used as the root node as a tree and directly use DFS? Code: # Include Ultraviolet A 11748-ri
Ultraviolet A 10821-constructing BST Question Link With a 1-N number, you must construct a BST with a height not greater than H and have the smallest Lexicographic Order. The output sequence Idea: greedy construction. Since the Lexicographic Order is the smallest, the root of each subtree should be as small as possible, that is, the right subtree should be filled up as much as possible. Follow this policy to construct DFS. Code: # Include
Label: style HTTP color OS Io for Ar code Ultraviolet A 1462-fuzzy Google suggest Question Link To simulate Google's fuzzy search, you must first have some text, and then enter a word for query each time. This word can be operated up to Ti times. Each operation can delete one character and modify one character, or add a character and ask how many prefixes can this word match at most. Idea: Build a dictionary tree, store the number of times each node
again ). Then some local words are given, and you need to output the corresponding English words.
Analysis and Summary:English words and local words are simple mappings. When the number of questions reaches 100,000, hash is used to create a ing or directly sort the questions and then perform binary search. Even if the problem can be barely passed, the speed should be unsatisfactory.Therefore, the best way to do this is to use a hash table to establish a ing relationship.The speed is good. I ran
ascending sequence ,...... N, which exists in the array arr. For each application form, assuming A to B, swap (arr [A], arr [B]).After processing all the data, determine whether the sequence is the same as the original sequence. If yes, the conditions are met. Otherwise, it will not work. (Because for each swap (arr [A]), arr [B]) If there is A swap (arr [B], arr [A]), so it is equivalent to restoring the original arrangement)
[Cpp]/** Ultraviolet A
Ultraviolet A 1556-Disk Tree (Dictionary Tree)
Question connection: Ultraviolet A 1556-Disk Tree
Give N directory relationships and then output the entire file directory in lexicographically.
Solution: Use each directory name as a character to create a dictionary tree. map can be used to optimize the relationship between each node.
#include
#include
#include
#include
#inclu
Ultraviolet A 11573-Ocean Currents (BFS + priority queue)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
Ultraviolet A 436-Arbitrage (II) (floyd)Ultraviolet A 436-Arbitrage (II)
Question Link
Given the exchange rate of currencies in some countries, I wonder if I can make money grow through constant currency exchange.
Train of Thought: floyd. After the event is finished, check whether the connection is greater than 1.
Code:
#include
#include
#include
#include
#include
usin
Ultraviolet A 12130-Summits (BFS)
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
Ultraviolet A 12338-Anti-Rhyme Pairs (suffix array + RMQ)Ultraviolet A 12338-Anti-Rhyme Pairs
Question Link
Given some strings, obtain the length of the longest common prefix of the two strings each time.
Train of Thought: sort the strings to find the array of height and rank, and then use RMQ to query
Code:
#include
#include
#include
#include
#include using namespace std;co
Ultraviolet A 11732-strcmp () Anyone? (Trie)Ultraviolet A 11732-strcmp () Anyone?
Question Link
Meaning: given some strings, we need to compare them by two or two times. (Note: if a character is the same, it must be compared to '\ 0' for two times)
Idea: Create a Trie tree. In each build process, the successor node is the same node. We need to compare the ans + val * 2 twice. Otherwise, the ans + val nodes
Ultraviolet a 1493-Draw a Mess (and query set)Ultraviolet a 1493-Draw a Mess
Question Link
There are four operations on an n * m plane. The corresponding area is colored as v (1
Train of Thought: Check the set, because the color coated will cover, so that we can perform the reverse operation, so that each operation can not be painted if there is a color before, if not, you can paint, then there are a total
Ultraviolet A 11255-neck133 (replacement)
Link to the question: Ultraviolet A 11255-neck.pdf
Given the number of beads in three colors, it is required that all beads use different types of necklaces, and rotating and turning are treated as the same.
Solution: Calculate the equivalence class, polya.
Rotation: 0, 1 ,~ N-1-1.
Flip: Consider n as an odd or even number. If n is an odd number and n symmetric a
Ultraviolet A 10651 Pebble Solitaire (BFS)Ultraviolet A 10651 Pebble Solitaire
Pebble solitaire is an interesting game. this is a game where you are given a board with an arrangement of small cavities, initially all but one occupied by a pebble each. the aim of the game is to remove as your pebbles as possible from the board. pebbles disappear from the board as a result of a move. A move is possible if ther
. if thereIs still a tie, choose the one that has Ds as long as possible at Lake 2, and so on. Insert a blank line between cases.
Sample Input
2110 12 524410 15 20 170 3 4 31 2 34410 15 50 300 3 4 31 2 30
Sample output
45, 5Number of fish expected: 31240, 0, 0, 0Number of fish expected: 480115, 10, 50, 35Number of fish expected: 724
[Analysis and Summary]
A greedy Question of the Super classic, the first example of the greedy chapter in the lrj black book.
I implemented it using heap.
[Code
Question link:
Ultraviolet A: http://uva.onlinejudge.org/index.php? Option = com_onlinejudge Itemid = 8 category = 24 page = show_problem problem = 2498
HDU: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 3172
Type: query set, hash
Original question:
These days, you can do all sorts of things online. for example, you can use varous websites to make virtual friends. for some people, growing their social network (their friends, their friends 'Fri
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.