A. Original Topic Requirements
Time limit: 10000ms
Single point time limit: 1000ms
Memory Limit: 256MB
Describe
Little Hi and Little Ho are playing a decryption game recently, they need to take control of the characters in a primitive jungle to explore, collect props, and find the last treasure. Now the characters they control come to a big lake. There are n islets on the lake (ref. 1. N), as well as the M-seat bridge connecting the islets. Each wooden bridge has a treasure chest, which seems to contain what props.
Beside the lake there is a boatman, the Boatman told the protagonist. He can carry the protagonist to any island, and can be from any island to carry the protagonist back to the lake, but the protagonist has only one time back and forth opportunity. At the same time, the Boatman told the protagonist that the bridge between the islands is very fragile, after one pass will be broken off.
Because I do not know what props in the chest, small hi and small ho think that if you can put all the props collected is certainly the best, then for the current situation of the island and wooden bridge, can all props collected?
For example, a map consisting of 6 islets and 8 bridges:
The protagonist can reach the island of 4th, and then follow the order of 4->1->2->4->5->6->3->2->5 to reach the island of 5th, then the boatman to the island of 5th will lead back to the lake. This leads to the collection of all the props on the bridge.
Hint: Oralu's decision
Input
Line 1th: 2 positive integers, n,m. Indicates the number of islands and the number of wooden bridges respectively. 1≤n≤10,000,1≤m≤50,000
2nd.. M+1 lines: 2 integers per line, u,v. Indicates that a wooden bridge is connected to an island numbered U and V, and that there may be multiple bridges between the two islands. 1≤u,v≤n
Output
Line 1th: A string, if you can collect all the props output "full", otherwise output "part".
样例输入681214242523364556样例输出Full
2. Analysis Ideas
The first feeling to get this problem is to examine the concept of the degree of the graph, that is, the maximum number of connected graphs can only have two nodes is odd degrees, if more than two, obviously is not possible.
3. Submit Error Analysis
1. The front side compile error is mainly our code contains the Memset function, this is in the String.h file, but we do not include. (g++ is not the same as VS, it can be used in VS)
2. The reason for the 3rd commit error is that we are outputting full judgment conditions written in
if2) cout"Full" << endl; else cout"Part" << endl;
That is to say, we ignore all the circumstances of an even number of degrees, leading directly to the answer is WA.
* <-_->!!
Modified AC.
4. The source code is as follows
//================== "The determination of the" Euler's Road "===============//@ input//Line 1th: 2 positive integers, N, M. Indicates the number of islands and the number of wooden bridges respectively. 1≤n≤10, 000,1≤m≤50,//2nd. M + 1 lines: 2 integers per line, u, v. Indicates that a wooden bridge is connected to an island numbered U and V, and that there may be multiple bridges between the two islands. 1≤u, V≤n//@ output//Line 1th: A string, if you can collect all the props output "full", otherwise output "part". //================== "End of Oralu judgment" ===============#include <iostream>#include <string.h>using namespace STD;intN =0;intM =0;int* * Ppbridge = NULL;int* Pdegree = NULL;voidInit () {Cin>> N >> M;if(N <1|| N >10000|| M <1|| M >50000) {Cerr<<"Error Input"<< Endl;Exit(0); } Ppbridge =New int* [M]; for(inti =0; I! = M; i++) {Ppbridge[i] =New int[2];Cin>> ppbridge[i][0] >> ppbridge[i][1]; } Pdegree =New int[N];memset(Pdegree,0,sizeof(int) * N);}voidDestroy () { for(inti =0; I! = M; i++) {if(NULL! = Ppbridge[i])DeletePpbridge[i]; }if(Ppbridge)Delete[] Ppbridge;}//============= "calculate the degree of all nodes" ===========voidComputedegree () { for(inti =0; I! = M; i++) {pdegree[ppbridge[i][0] -1] +=1; pdegree[ppbridge[i][1] -1] +=1; }}intJudge () {intOdd_num =0; for(inti =0; I! = N; i++) Odd_num = pdegree[i]%2==0? Odd_num:odd_num +1;returnOdd_num;}intMain () {init (); Computedegree ();intOdd_num = Judge ();if(Odd_num <=2)cout<<"Full"<< Endl;Else cout<<"part"<< Endl; Destroy ();return 0;}
C Implementation method of Hihocode 49th Zhou