After optimization, you do not need to define an array to store the longest sequence of the current element, but store the longest sequence while inputting data.
Disadvantage: the stored array is only the length of the longest sequence, but the
Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1166
Solution:
You can use Google to search for the line tree or segment tree.
I am using static achievements.
CodeAs follows:
# Include # define lson L, M, root 1;
1. Try not to use the immediate number, but define it as a constant with # define for later modification.2. Use the sizeof () Macro, instead of directly using the number of bytes occupied by the variable.3. Use parentheses for slightly complex
BelowProgramWhat is the output result? Why?
# Include # include # include using namespace STD; struct node {char ch; int cost; node () {CH = '\ 0 '; cost = 0;} // commented out this function, without any impact on the entire program bool
Original question link:
Http://acm.hust.edu.cn/thx/problem.php? Id = 1010
It is not difficult to understand this question. Generally, the first solution is brute-force solution. However, for ACM, the brute-force solution usually gets TLE,
I wrote it for an hour and want to simulate it. As a result, there are many points that cannot be solved at the end, that is
[(])] You only need to add one [, but I cannot judge the characters After STR [I], because I can only judge the elements
I just got a question from AC. I need to initialize the array part to zero. In order to make it simple, I used memset to set the entire array to zero. In my opinion, the speed of the memset function is amazing, unexpectedly, I had to review the
Problem descriptionThere is a row of trees on the road with a length of L outside the gate of a school. The interval between every two adjacent trees is 1 meter. WeWe can regard the road as a digital axis, where one end of the road is 0 and the
Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 2680
Question:
A directed graph, a starting point set, and an ending point ....
Solution:
1. add a super source point, connect the starting point set to the super source point, and set
Side:How can I determine whether a binary tree is a Complete Binary Tree? At first, I forgot the definition of a full binary tree. The interviewer reminded me that I understood what it was .. Khan. What I answered at the time was to convert it into
I have always thought that recursion is quite understandable. I can understand it and use it. It turns out that I have been not very familiar with it and can use it so skillfully...
An Inverse polish expression is an arithmetic expression prefixed
Problem definition:
A number sequence Bi, when B1
The longest length of these subsequences is 4, for example, subsequences (1, 3, 5, 8 ).
Your task is to find the length of the longest ascending subsequence for the given sequence.
Input data
The
The most common problems with substrings are:
1. Maximum substring and
2. Longest ascending subsequence
3. Longest public substring
4. Longest Common subsequence
5. Maximum repeated substrings
6. Minimum overwrite substring
Next we will
We all know about the Huffman encoding. The following program only performs exercises. If you enter any length of characters, the codes are automatically encoded based on the number of occurrences of the characters. The shorter the encoding length,
Abstract means to extract the commonalities of different things. Why use the word "thing? Because abstraction may not be a thing or a thing.Abstract is one of the important ideas of programming. Its main purpose is to reduce code duplication and
The speed of One-Step Optimization is much faster than that of insert sorting, and random algorithms can be easily introduced to avoid the worst case.
#include#include#include#include#include //#include using namespace std;#define DEBUGconst int
When we need to sort the linked list, because we cannot perform random access to its elements, it is more suitable for the use of Merge Sorting. The well-known fast sorting applies to the linked list, and the efficiency is also very low, the reason
Given two linked lists, calculate the Union (linked list) and intersection (linked list) of the two linked lists ). Elements in the Union (linked list) and intersection (linked list) are not required to be ordered.
For example, enter:
List1: 10-> 15-
Problem definition:
Write a program to swap odd and even bits in an integer with as few instructions as possible (E. g, bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, etc)
The Code is as follows. I thought about it for one night and
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