http://poj.org/problem?id=3041There are K asteroids in the N*n grid, where the asteroid I is (RI,CI), and now there is a powerful weapon that can blast a whole row or a whole array of asteroids to ashes with a luminous speed, and to use this weapon to destroy all asteroids requires at least a few luminous beams.Mainly the composition, will each line into a point, constitute a set of 1, each column also as a point, the composition of the set 2, each obstacle position coordinates will set 1 and se
the longest route to the hotel. Note that there must be no forks on the road and the road is backward.
Direct dfs + pruning on the line, the graph is saved with set... Look at others using a one-dimensional array.
Code:
/** Author: illuz
* Blog: http://blog.csdn.net/hcbbt* File: b.cpp* Create Date: 2013-10-02 00:17:29* Descripton: b */#include
#include
#include
#include
#include using namespace std;#define rep(i, n) for (int
characters in "AGCT", which is the DNA segments causing inherited disease.The last line of the that test case is a non-empty string of length not greater than-containing only characters in "AGCT", Which is the DNA to be repaired.The last test was followed by a line containing one zeros.Outputfor each test case, print a line containing the "test Case number" (beginning with 1) followed by theNumber of characters which need to be changed. If it ' s impossible to repair the given DNA, print-1.Samp
DescriptionThe farmer John's farm suffered an earthquake. Some of the cattle sheds were damaged, but fortunately, all the road stalls between the cattle can be used. FJ's Farm has P (1 Input* Line 1th: Three spaces separate number: P, C, and N* 2nd. C+1 lines: Two spaces per line: a_i and B_i * c+2..c+n+1 line: One number per line: Report_jOutput* Line 1th: Number of cows that cannot return to the farm at least (including damaged barns).Sample Input4 3 11 22 33 43Sample Output3HINTThe Barn 2 was
Test instructions: To a city to get money, to leave to spend money. There is cash at the beginning. The city is circular, ask from which start, can on the way any time money >=0;A start pointer I, a trailing pointer J. Indicates an interval. If the conditional ++j is met and the proceeds are added to the sum (the earnings may be negative). Non-conforming is ++i, and the return from sum proceeds until the sum>=0; interval length is n, the position of I is the result.Proof of correctness: Suppose
integer for each test case:the lowest intersection number @ which a new fire station SH Ould is built so as to minimize the maximum distance from any intersection to the nearest fire station.
Sample input
1 621 2 102 3 103 4 104 5 105 6 106 1 10
Sample output
5
Source
University of Waterloo Local Contest 199
Uploaded by
Zhang Yunzun
Helples
1OutputNOInput4 7.. x.xx.. Xx.. X.X... X..X......2 21 6OutputYESTitle, every step, go through that place into a broken ice, if you go again will fall, you can not beat in situ to make the ice change state, and your final goal is not just to find the destination, and to make it into X and then re-enterOriginally I wanted to think about the situation, such as the destination is X or. , and then judge the condition is changed, and then count, mark is not a problem, and consider from the origin to
Struct node {int data; node * Next;}; // create a linked list and enter a number as the input. If the input is 0, the linked list ends (0 is excluded) node * creat () {node * head, * P, * s; int X, cycle = 1; head = (node *) malloc (sizeof (node); P = head; while (cycle) {cout // Calculate the length of the linked list int computlength (node * head) {node * P; int n = 0; If (Head = NULL) {return 0;} p = head; while (P! = NULL) {n ++; P = p-> next;} return N ;}// Print the data void printlist (no
Http://poj.org/problem? Id = 3256
Store the paths of N farms in an adjacent table, record the initial number of cattle in each farm, and query the number and number of cattle in each farm along the path DFS.
Code:# Include # Include Using namespace STD;
Int num [1001];
Int sum [1001];
Int head [1001];
Bool vis [1001];
Int X;
Struct past {
Int V, NEX;
} Edge [2, 10001];
Void addedge (int u, int v ){
Edge [X]. V = V;
Edge [X].
HDU 4411 Arrest fee stream
Question link: Click the open link
Question:
Given n + 1 vertex ([0, n]) an undirected graph of m edge. The starting point is 0, and k people are initially at the starting point,
Traversing the graph enables at least one person to walk each vertex and the I-1 must have been traversed when traversing the I point.
To minimize the path and number of k people, k people should return to the starting point.
Ideas:
Cost flow, because for a person, the sequence of the person's
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.