POj 1753 -- Flip Game -- bitwise operation + BFS
Flip Game
Time Limit:1000 MS
Memory Limit:65536 K
Total Submissions:30669
Accepted:13345
DescriptionFlip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. one side of each piece is white and the other one is black and each piece is lying either it's blac
Spoj Goblin Wars (simple bfs), spojbfsJ-Goblin WarsTime Limit:432 MSMemory Limit:1572864KB64bit IO Format:% Lld % lluSubmitStatusPracticeSPOJ AMR11J
Description
The wizards and witches of Hogwarts School of Witchcraft found Prof. binn's History of Magic lesson to be no less boring than you found your own history classes. recently Binns has been droning on about Goblin wars, and which goblin civilization fought which group of centaurs where etc. the
Three NYOJ21 water cups (Classic problem bfs)
Three water cups are provided in different sizes. Only the largest water cup is filled with water, and the other two are empty. The three water cups pour water between each other, and the water cup is not identified, it can only be calculated based on the given water cup volume. Now, you need to write a program that outputs the minimum number of times the initial state reaches the target State.
HDU 1072 Nightmare (whether he can leave before the bomb explosion with a time bomb-BFS + DP)
Nightmare
Time Limit:1000 MS
Memory Limit:32768KB
64bit IO Format:% I64d % I64u
DescriptionIgnatius had a nightmare last night. he found himself in a labyrinth with a time bomb on him. the labyrinth has an exit, Ignatius shocould get out of the labyrinth before the bomb explodes. the initial exploding time of the bomb is set to 6 minutes. to prevent the bo
Hdu 3152 Obstacle Course bfs + priority queue# Include
# Include
# Include
# Include
# Include
Using namespace std;
Const int maxn = 130;
Const int inf = 0x7fffffff;
Int N;
Int dx [4] = {-1, 0, 1, 0 };
Int dy [4] = {0, 1, 0,-1 };
Int line [maxn] [maxn];
Int vis [maxn] [maxn];
Int ans = inf;
Struct node
{
Int x, y;
Int sum;
};
Str
groups involved in the search together. That's, if the original group walks five steps, then splits into both groups each walking three steps, the total distance Is 11=5+3+3.InputOn the first line of input there are one integer, N OutputFor every test case, output one line containing the minimal cost of a succesful search of the maze leaving no aliens alive .Sample Input5##### #A #a### # a# #S ####### 7 7##### #AAA # # # # # # # # # # # # #AAA a## Sample Output811SourceSvenskt m?sterskap
TopicsGiven n points and M-bars, starting from point 1, find the path with the number of the top of the path less than or equal to K, and find the minimum value of the longest edge length in the path of all paths that meet the criteria. Topic Link: two points Minimize the maximum value, consider using a binary search. To sort all the side length, two points, for each selected edge length, determine if there is a path that satisfies all the edge lengths on the path that are less than or equal to
Question G: Super Prime (Sprime)
time limit: 1 Sec memory limit: up to MBSubmitted by: Resolution: 11Submitted State [Discussion Version]
Title DescriptionA super prime is a prime number that is always guaranteed to be prime, for example, by removing the following number:373->37->3This is a super prime number with a length of 3.InputEnter an integer n (10≤n≤108).OutputFrom small to large output all super primes less than or equal to N, leaving a space between each super prime. There is
Question A: Mother's Milk (milk)
time limit: 1 Sec memory limit: MBSubmitted by: + Resolution: 8Submitted State [Discussion Version]
Title DescriptionFarmer John has three volumes of a, B, c-liter barrels, a, B, and C are three from 1 to 20 of integers, initially, a and B barrels are empty, and the C bucket is filled with milk. Sometimes John poured milk from one barrel to another until it was filled with barrels or the original bucket was empty. Of course every infusion is complete, be
The shortest sequence that contains all n DNA fragments and does not contain any one of the virus fragments.It is easy to build an AC automaton with all the DNA fragments and virus fragments, and when the fail is constructed, the node suffix is a DNA or a virus, then dp[s][u] indicates that the set containing the DNA fragment is s and the suffix state is the shortest sequence length of the first U node of the automaton, Then follow the AC automaton to avoid the virus string transfer.However, the
Hdu 2531 Catch himBlock of BFS, the search is done in a block, the rest of the point with the offset value of the point is indicated#include #include#include#include#include#include#defineN 105using namespacestd;intdx[4]={0,1,0,-1};intdy[4]={1,0,-1,0};intPx[n],py[n];//Offset ValueBOOLVis[n][n];CharMaze[n][n];intAns,pn,h,w;typedefstructnode{intx, y; intDis;} Node;queueQ;BOOLOkintXxintyy) { intI,x,y; for(i=1; i) {x=xx+px[i]; y=yy+Py[i]; if(x1|| X>h
groups involved in the search together. That's, if the original group walks five steps, then splits into both groups each walking three steps, the total distance Is 11=5+3+3.InputOn the first line of input there are one integer, N OutputFor every test case, output one line containing the minimal cost of a succesful search of the maze leaving no aliens alive .Sample Input5##### #A #a### # a# #S ####### 7 7##### #AAA # # # # # # # # # # # # #AAA a## Sample Output811"Test Instructions" in a
shortest sequence of operations.The first sequence of operations that appears in the dictionary order in the second row, represented by a string, outputs 60 characters per line, except for the last line.Sample input2 6 8 4 5 7 3 1Sample output7BCABCCBTipsThe input target state of the sample is obtained by the BCABCCB 7-step operation."Analysis" into a one-dimensional string, anyway there are only eight, violent bfs.#include #include#include#include#i
(9+7) , wherezi is the answer for i-th query.Sample Input13 31 2 33 41 23 9Sample Output10 Test Instructions: Two operations, one is the x^y,y is the AI, there is a change in the x bits of one, equivalent to a 2 of the J-time (j=0,1,2,3,4 ...);Ask S to t at least how many times it takes, Ans=sigama (I*zi) mod (1e9+7); Thinking: Ah ah ah ah ah, I do not know how to do, and finally read the solution to the question only with the s^t to react to it; This is related to the nature of the Xor op
Given n nodes labeled from 0 n-1 to and a list of undirected edges (each edge is a pair of nodes), write a funct Ion to check whether these edges make up a valid tree.The main problem is to Judge 1. Is there a loop 2. Whether it is a connected graphYou can use DFS, BFS and Union find,union find most appropriate.For DFS and BFS, the first is to establish the adjacent list, the edges connection of all the con
Test instructions: A three-dimensional maze, the three-side length is r,n,m, (Analysis: The state is only 30*30*30,BFS can be, no meaning#include #include#include#include#includeusing namespacestd;Const intmaxn= *;CharG[MAXN][MAXN][MAXN];intvis[maxn][maxn][maxn],r,n,m;intSx,sy,sz,ex,ey,ez;Const intdz[7]={0,0,0,0,0,1,-1};Const intdx[7]={0,-1,1,0,0,0,0};Const intdy[7]={0,0,0,-1,1,0,0};structnode{intx,y,z,v; Node (intAintBintCintd): X (a), Y (b), z (c),
Topic:http://acm.hdu.edu.cn/showproblem.php?pid=1429Test instructions: Maze problem, more doors and keys. The first state of compression, the use of binary to save whether to get the key, three-dimensional array judge[][][], record the state, why will go "back", because in the minimum number of walking, the situation can only be taken back when the key to return, but after the key is taken, Although at the same point, its state has changed (the key has none). Can be considered as the key to the
Simple for the use of BFS, but still write too slow to write the TMD 1H, mainly not familiar with, after slowly familiar with, the model has been able to establish, the main problem is in the direction of the array of use above, must remember is starting from 0, and not starting from 1, resulting in errors.#include #include#includeusing namespacestd;/*BFS*///Array of directionsintnextx[8][2]={ {-1,-2},
An ordinary BFS if not look at the sample and the explanation of input ...The four 0 is really god-like example and was misled by input to think that each point in order has a marking the end of the portal to a point of the labelAnd what's the result? Endless Runtime error ... The runtime error that lasted half the training game.And then actually the end of the portal gives the coordinates, forget it-1.Then the vector forgot to emptyAnd then when the
shortest number of steps required from a four-digit prime number to another four-digit prime number, each step can only change one digit, and the number of changes must be four-digit numberThis is a typical digital search problem, to find the shortest circuit so with BFS, the difficulty lies in the conversion of analog number, and also pay attention to the border control#include #include#include#include#include#includeusing namespacestd;Const intmaxn
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.