i = A; I 3 #defineREP (I, A, b) for (int i = A; I 4 #defineDrep (I, A, b) for (int i = A; I >= b; i--)5 #definePB Push_back6 #defineMP Make_pair7 #defineCLR (x) memset (x, 0, sizeof (x));8 #defineXX First9 #defineyy secondTen using namespacestd; OnetypedefLong Longi64; Atypedef pairint,int>PII; - Const intINF = ~0U>>1; - Consti64 INF = ~0ull>>1; the //*************************** - Const intMAXN =805; - CharMA[MAXN][MAXN]; -
≤). OutputOutputs an integer that takes time for the longest walk of the clone in a round trip.Sample Input and output
Sample Input
Sample Output
4 8 21 2 41 3 21 4 72 1 12 3 53 1 23 4 44 2 3
10
Dijkstra: two times. The first time along, the second time against. Here the storage of the graph is not suitable for the forward star, suitable for the matrix storage, the reverse side of the time is more convenient.Code:1#include 2#include 3#i
attended by up to a total.If m=1, of course, according to the end time sort, can.Here, simply deform, set b[j] for the point where the J-person is currently located (initially 0), for the first meeting, if there are more than one person to meet the criteria, select B[j] the largest one.Attached code:1#include 2#include 3#include 4#include 5#include 6 using namespacestd;7 8typedef pairint,int>PII;9 #defineF FirstTen #defineS Second One A intMain () {
, one of its front elements, which satisfies g (i ') >=g (i), Then this element should not be preserved. Otherwise it should be added to this two-tuple, after adding this two-tuple, in order to maintain the nature of the ordered table, but also to check the deletion of some g (i*) small elements.Finally think more thoroughly, the implementation of the way is set, with the pair to ensure the two-tuple, pair comparison is the first dimension, compared to the second dimension. As for the second imp
variables When a variable is enclosed in double quotes, the variable is concatenated with the contents of the double quotation mark, and the variable is exported as a string when the variable is included in the single quotation mark.
The heredoc structure form first uses the delimiter to represent the string (GOD, then the string, and finally ends the string with the supplied identifier. Identifiers can be changed according to preferences, to maintain consistency
NULL Null is a null type, is in
I was thinking of a single source multi-point very good solution but multi-source single-point How to solve and I found that as long as the upside down.Save the input and process the DIS1 re-init once and then enter processing DIS2 output max (Dis1[i] + dis2[i])#include #includestring>#include#include#include#include#include#include#includeSet>#include#defineINF 0x3f3f3f3fusing namespaceStd;typedef pairint,int>PII;structcmp{BOOL operator()(ConstPII A,
DescriptionDefine a two-dimensional array:int maze[5][5] = {0, 1, 0, 0, 0,0, 1, 0, 1, 0,0, 0, 0, 0, 0,0, 1, 1, 1, 0,0, 0, 0, 1, 0,};It represents a maze, of which 1 represents a wall, 0 means that the road can be walked, can only walk sideways or vertical walk, can not be inclined to walk, asked to compile the program to find the shortest route from the upper left to the lower right corner.Water problem, BFS then record the path just fine. The code is as follows:#include #include#include#include
Main topic:Select some squares to ensure that the corresponding lattice of the attraction is connected by these lattices, guaranteeing the weights and minimums of all the selected lattices.This is equivalent to the smallest spanning tree that is understood to form all pointsThe number of points here is small, so you can compress the state of each pointF[st][i] Indicates that connectivity is at least St, and the minimum distance through the I pointEquation 1.f[st][i] = min{f[s][i] + f[st-s][i]} (
Sgu262: Symbol Recognition (pressure DP)
Question:
Given
K
Items
N? M
Of
01
Matrix
Si
, Find
1
As few as possible
N? M
Of
01
Matrix
P
, Meet
K
The interaction between a matrix and the matrix is different, that is, the matrix can represent the given
K
Matrix.
Analysis:
There are several pressure issues.
DP
Let's talk about it here.
Assume that
Si
And
P
Is defined
Qi
, Whose ID is
Ti
In the initia
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;const int N = 100005;typedef pair
pii
the constant. The third parameter, "Case_sensitive", is an optional parameter, specifying whether it is case sensitive, set to true to be insensitive, and generally without specifying a third parameter, the value of the default third parameter is False. (note: string indicates that the parameter type is a string type, mixed indicates that the parameter type can be accepted as many different types, case_sensitive = True indicates that the default is Boolean type True) $p = "
Test instructionsGive a diagram some side, ensure the diagram is connectedQ for each edge, if the edge is removed, some points in the graph are not connected. These points (U,V) are required to make you as small as possible, V as large as possible, and output such (U,V). Otherwise output 0 0.1#include 2 using namespacestd;3 Const intMAXN = 1e5 +1;4typedef pair int,int>PII;5VectorG[MAXN];6 BOOLISBRIDGE[MAXN];7 intCLK, PRE[MAXN], LOW[MAXN];8 intIDX, MAX
The idea of this topic is very simple, we just need to enumerate each vertex as the destination, and then take the sum of the minimum distance as the answer. At first I used Floyd to find out the minimum distance between all points at once, but it timed out.The next time you enumerate a point, use the heap-optimized dijkstral to find the shortest path to the rest of the point, so it's too late. The adjacency matrix of the graph is also simulated with an array in the algorithm.The code is as foll
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.