integer Wi indicates the weight of the i-th.Then M lines follow. Each line represents a query. It contains integers L and R, meaning the king wanted to ask about the situation if he sent all rabbits from the L-th one to the r-th one into prison.(1 The input ends with n = 0 and M = 0.OutputFor every query, output one line indicating the answer.Sample Input3 22 1 41 21 36 43 6 1 2 5 31 34 64 42 60 0Sample Output211312HintIn the second case, the answer of the 4-th query are 2, because only 1 and 5
ChannelTest instructions: Given n points, M-Edge, now to the edge of the direction of the point to make the difference between the degree and the degree of not more than 1Ideas:The determination of the degree and the penetration of each point, if the degree of large, first reverse search (each search a side u,v think this is a V to U of the forward side), conversely, to do a forward search (every search to a side u,v think this is a U to V of the forward side), has been searched until the edge c
question. Hope to be able to persist in the future of each game to complete the title.
AC Code/************************************************************************* > File Name:pf.cpp > Author:z nl1087 > Mail: [email protected] > Created time: 46/11 16:36:14 2015 ************************************** **********************************/#include #include #include #include #include #include #include #include #include #include #define LL Long Longusing namespace STD;intN,k; LL s[300005]; vect
Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1243Analysis: Dp[i][j] represents the maximum score of a former J-bomb before I burst into the blast. is actually the longest common subsequence plus each letter value is 1, here each letter represents the value changes a bit.State transition equation: if (s1[i-1]==s2[j-1]) dp[nxt][j]=dp[cur][j-1]+val[s1[i-1]];else Dp[nxt][j]=max (Dp[
on.Sign[]={1, 1, 1, 0}.In the second case, find 1 from the back to the first position that appears to be 3.Constructed Hamilton Road: V5-> V4, V3, V2, V1, and so on.(Just give me a bar ~ ~ ~)Sign[]={1, 1, 1, 1}.Likewise the last one is 1, which represents the existence of The construction of Hamilton Road: V1, V2, V3, V4, V5. The above is when the n=4 (n+1=5), with the diagram to illustrate the process of the algorithm.Note that it is not looking for the point before the point number, that is,
than one tree, 22 violent rides. Different or this kind of thing do not know or do not play for the better. And then this is just violence, the standard way to multiply O (n^2) with FWT down to O (Nlogn), really lonely as Snow =1#include 2#include 3#include 4#include 5#include 6 intfa[100010];7 intMain ()8 {9Freopen ("che.in","W", stdout);TenSrand (Time (0)); One intn=100000;p rintf ("%d\n", n); A for(intI=2; i -; i++) printf ("#df", rand ()% (I-1)); - for(intI=401; i"%d", rand (
Title DescriptionTransmission DoorExercisesThe people who live are all the people who don't go home and all the people who come to see XI, and some dorms are all students Yi.s->xi,1 yi->t,1 for the IJ know, xi->yi,1That is, the maximum match.Code#include #include #include #include using namespace STD;Const intmax_n= -;Const intmax_n=max_n*2+2;Const intMax_m=max_n*max_n;Const intmax_e=max_m*2;Const intinf=2e9;intT,n,n,a,b,maxflow;intSchool[max_n],home[max_n],known[max_n][max_n],a[max_n],b[max_n];
Description When someone reads a paper, a paper is made up of many words. But he found a word that appeared many times in the paper and now wants to know how many times each word appears in the paper. Input The first integer n, which indicates how many words there are. The next n lines are one word per line, and each word is made up of lowercase letters. Output outputs n integers, and the number in line I indicates how many times the first word appears in the article. Sample Input3AAaAaaSample O
Before it seems that the network flow of the construction of the problem is relatively few ah ... Now let's do a little. The first is the template. poj1273 Grassland Drainage #include #include#include#include#includestring.h>#include#include#includeSet>#includeusing namespacestd;#defineSZ 233333intn,m=1; typedefLong Longll;intFst[sz],nxt[sz],vb[sz]; ll Cap[sz];voidAD_DL (intAintb,ll c) { ++m; Nxt[m]=fst[
The direction of the graph in if between two points can reach each other, it is said that the two points strong connectivity, if all points within a point set can reach each other, then the point set is a strong connected component of the graph, and we need to find all the strongly connected components of the graph, so the Tarjan algorithm to strong connectivity, and a connected block is shrunk to a point so that it can form a direction-free graph, which is helpful for solving problems.The metho
:224DescriptionData range:For 100% of data,N
Problem analysisEarly learned that this "Mo Team Board Problem" has a tree-like array solution but slow to learn ...Obviously the answer is reduced, and no matter whether the answer is outside the range or not, it will not affect the answer within the interval.Here is a kind of routine or technique: use $nxt[i]$ to represent the next element with the same nature of the $i$ position, then delete the $
time we get \ (lp\, \ rp\), then we need to determine whether the above equation is true.If it is, add this interval to the answer set, otherwise \ (continue\).Given \ (lp\, \ rp\) , how to quickly ask \ (f (LP,RP) \) ? Consider multiplying.The original interval sequence is sorted by the left endpoint, and a new interval sequence is obtained.Order \ (nxt[x][d]\) indicates the selection of \ (2^d\) intervals (excluding \ (x\)) from section \ (x\) , an
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.