This question .... The test instructions is very long. The general meaning is to give a maze, the maze has 16 of the state. Then each lattice in the maze consists of a hexadecimal number, and then converts the number to 2, clockwise around a circle to indicate whether it is possible to walk around the lattice, 0 to walk, and 1 to not go =_=And then let you judge which of the 4 types of Maze the maze is.Each labyrinth is guaranteed to have only one inlet and outlet. And there's only one wall betw
Idea: Build a map!!! Then enumerate the maximum levels and find the shortest path to item 1.1 2#include 3#include 4#include string.h>5 #defineMAXN 0X3FFFFFF6 using namespacestd;7typedef pairint,int>PII;8 intvisit[ the],dis[ the],map[ the][ the],n,m,v,l,p,x,t,vis[ the],liv[ the],sb,w,cas;9priority_queueQQ;Ten intMain () One { A intI,j,max; - while(SCANF ("%d%d",m,N)) { - if(n==0m==0) the Break; -Memset (LIV,0,sizeof(L
Very naked a Dijk algorithm problem, because the vertex number is too many can not be represented by the adjacency matrix, so the critical table is used to representAC Code#include #includestring.h>#include#include#include#includeusing namespacestd;using namespacestd;Const intmaxn=2*50000;#defineINF 99999999structnode{intv; intu; intW; intNext;} V[MAXN];intHEAD[MAXN];intD[MAXN];intn,m,s,t;intTol;intDone[maxn];typedef pairint,int>PII; priority_queueQ;v
];structEdge {intto, Next, W;} EDGE[MAXN*2];typedef pairint,int>PII;intDIS1[MAXN], DIS2[MAXN], DIS[MAXN];voidinit () {tot=0; memset (Head,-1,sizeof(head));}voidAddedge (intUintVintW) {edge[tot].to=v; EDGE[TOT].W=W; Edge[tot].next=Head[u]; Head[u]= tot++;}intPos, Maxx;BOOLVIS[MAXN];voidBFsintUint*dist)//search the distance from the U point to each point and save it in the Dist{Maxx=0; QueueQ; memset (Vis,false,sizeof(VIS));
uva10986-sending Email (Dijkstra)Topic linksThe main topic: to n points, M edge, there is a starting point and end point, ask the shortest distance from the beginning to the end, not up to unreachable.Problem-solving ideas: The shortest path, Dijkstra algorithm.Code:#include #include #include #include using namespace STD;usingStd::make_pair;typedefpairint,int> Pii;priority_queue vector, GreaterConst intINF =0x3f3f3f3f;Const intMAXN =2e4;Const intMAXM
line of all test case consists of M integers, while the i-th number indicates the value of Si.Technical specification1. t≤152.0 3. The length of each word was less than and bigger than 0.4.1≤hi≤100.5. All the words in the input is different.6. All the words just consist of ' a '-' Z '.OutputFor each test case, the output of the string to engrave on a.If there ' s more than one possible answer, first output the shortest one. If There is still multiple solutions, output the smallest in lexicograp
Regional Contest problem solving: Spicy next door, into the pit! The range of k will exceed int, so it is better to use long long! I rewrote the code two times.1#include 2 using namespacestd;3 Const intMAXN =500010;4 Const intMoD =777777777;5 usingPII = pairint,int>;6 usingLL =Long Long;7 intscore[ +][ -];8 PII D[MAXN];9LL b[maxn],k[ +];Ten structPalindromictree { One intch[maxn][ -],FAIL[MAXN],CNT[MAXN],LEN[MAXN],S[MAXN]; A inttot,last,n,m;
The problem is to give you the number of n, and then give you M T and r of the sequence T value is 1 or 2, when the 1 is the number of n the first number of R is arranged in ascending order, when the number of the first n is 2 is a descending order, ask you this m operation sequence is how much? The first thing to be sure is that if there is an operation R greater than the previous R then the previous operation can be ignored, according to this property we can change the m operation to follow th
Set D (I, j) to the minimum length of the tree connecting the point I to the J point, there is a state transition equation:D (i, j) = min{D (i, K) + D (k + 1, j) + P[k].y-p[j].y + p[k+1].x-p[i].x}Then we use the quadrilateral inequality to optimize it.1#include 2#include 3#include 4#include 5#include 6 #defineMP Make_pair7 #defineX First8 #defineY Second9 using namespacestd;Ten Onetypedef pairint,int>PII; A - Const intMAXN = ++Ten; - Const intINF =0
double quotes). Otherwise, the output satisfies the nature of the number of squares.Sample Input5 5--+-+..| #...| ##S-+-t####.Sample Output2Sample DescriptionIf you mark an "X" on the map with a square of the satisfying nature , the map looks like this:--+-+..| #X..| ##S-+-t# # #XProblem solving: Direct search ...1#include 2#include 3#include 4#include 5 #definePII pair6 using namespacestd;7 Const intMAXN = -;8 CharMP[MAXN][MAXN];9 BOOLva[maxn][maxn],vb[maxn][maxn],e[maxn*maxn][maxn*MAXN];Ten i
A very challenging topic of direct violence to build the words of No doubt O (n^2) will be tle each layer of virtual a point and will let no point of the layer can also connect the pastRefer to the method of Kuangbin chicory two virtual points per layer n+i*2-1 is the entrance n+i*2 is the exit and then the one-way side.VA once, because MAXN should be twice times bigger than the data. Accidentally ignored as far as MAXM directly to 1e7#include #includestring>#include#include#include#include#incl
Problem Descriptionjohn has several lines. The lines is covered on the X axis. Let's a point which are covered by the most lines. John wants to know how many lines cover A.Inputthe first line contains a single integerT(1≤t≤) (The data forN> Less than cases), indicating the number of test cases.Each test case begins with an integern(1≤n≤5) , indicating the number of lines.Next N lines contains and integersXi andyi(1≤Xi≤Yi≤9) , describing a line. Outputfor each case, output an in
number of squares that can be coated with K is a+n-b, The number of squares that can only be painted in K-1 is x*n-(a+n-b); the coloring scheme for x lines is temp=k^ (a+n-b) * (K-1) ^ (x*n-(A+n-b)) and if temp=r, temp is the answerAgain consider the case of line x+1, if the X Act is not a color of the lattice, then the next row of its adjacent lattice coloring scheme is K, otherwise K-1, the number of K-1 can be painted C, then temp=temp*k^c* (K-1) ^ (n-c), if temp=r, then temp is the answerTh
http://www.lydsy.com/JudgeOnline/problem.php?id=2534Given the string s, the number of substrings in the form of ABA, where the length of B is L.Consider the two starting position x, Y (x1.y>x+l2.LCP (x, y) ≥y-x-lWe press the height from the large to the small enumeration, so that LCP becomes the current height, the two sets of statistical answers and merge. The statistical answer is to enumerate the points within the smaller collection of size as x or Y. Can be maintained with a balance tree or
Topic Links: http://acm.hdu.edu.cn/showproblem.php?pid=1874Thinking Analysis: The problem is given a graph, the starting point and the endpoint, the minimum distance from the starting point to the endpoint is required to find out;The shortest-circuit length from the starting point to all other points is calculated using the Dijkstra algorithm, if the shortest-circuit length is int_max, indicating that no path is connected from the starting point to the point;The code is as follows:#include #incl
(that is, e[pre[ E[t].to]].length > E[t].length), the edge recorded by the Pity Dorado (pre[e[t].to] = t) is updated.Code:
#include
#include
#include
#include
#include
#define INF 0X7FFFFFFFFFFFFFFF
#define PII Pair
using namespace Std;
Long Long s,n,m,pre[300002],tag[600002],u[600002],v[600002],next[600002],first[300002];
Long Long sum,d[300002],w[600002];
priority_queue
BOOL vis[300002];
void input () {
Long Long
During the course of learning network technology, we often see that Linux and Linux operating systems are increasingly popular with computer users, you may encounter hardware problems related to the installation and recognition of the Linux operating system. Here we will introduce how to install the Linux operating system and how to understand the Supported Hardware, I will share it with you here.
The CPU level must be PII, PIII, P4, K7, or K8 or abov
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.