Oralu Yi time limit: 10000ms single point time limit: 1000ms memory limit: 256MB description
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".
-
-
Sample input
-
-
6 81 21 42 42 52 33 64 55 6
-
-
Sample output
-
Full
Code: after Hiho verification, meet the requirements of the topic.
1 Importjava.util.ArrayList;2 ImportJava.util.Scanner;3 4 5 Public classMain {6 7 Public Static voidMain (string[] argv) {8 9Scanner in =NewScanner (system.in);Ten intm =in.nextint (); One intn =in.nextint (); A /* - * Use variable-length arrays instead of linked lists to describe the non-graph - */ theArraylist<integer>[] s =NewArraylist[m]; - for(inti=0; i<m; i++){ -S[i] =NewArraylist<integer>(); - } + for(intj=0; j<n; J + +){ - intA =in.nextint (); + intb =in.nextint (); AS[a-1].add (b-1); atS[b-1].add (A-1); - } - in.close (); - //System.out.println ("Begin check"); -Main Test =NewMain (); - /* in * See if there are 2 or 0 points with an odd number of degrees - */ to intBegin_state =test.firstsuccess (s); + if(begin_state==s.length) { -System.out.println ("part"); the return; * } $ Else{Panax Notoginseng //System.out.println (begin_state); - /* the * See if the graph is connected + */ A BooleanSecond =test.secondsuccess (S, begin_state); the if(second) +System.out.println ("full"); - Else $System.out.println ("part"); $ } - - } the - Public intfirstsuccess (arraylist[] s) {Wuyi intSuccess = 0; the intLeng =s.length; - intMax_simple=0; Wu for(inti=0; i<leng; i++){ - //System.out.println (s[i].tostring ()); About inttemp =s[i].size (); $ //System.out.print (temp); - if(temp%2==1){ -success++; -max_simple=i; A //System.out.println (i); + } the if(success>2) - Break; $ } the //System.out.println (success); the if(success==2| | Success==0) the returnmax_simple; the Else - returnLeng; in } the the Public BooleanSecondsuccess (arraylist[] s,intbegin) { About intLength =s.length; the int[] Add =New int[length]; the int[] Checked =New int[length]; theAdd[begin]=1; + intNumber=0; - while(true){ the intTemp=0;intNot_end=0;Bayi for(inti=0; i<length; i++){ the if(add[i]==1&&checked[i]==0){ thetemp=i; -not_end++; - Break; the } the } the if(not_end==0) the Break; - //System.out.println (temp); the for(intk=0; K<s[temp].size (); k++){ theadd[(int) S[temp].get (k)]=1; the }94Checked[temp]=1; number++; the } the //System.out.println (number); the if(number==length)98 return true; About Else - return false;101 }102}
Hiho---Eulerian graph