Hiho the 49th week. Topic 1: Oralu Yi "Tuola Road Problem"

Source: Internet
Author: User

Topic 1: Oralu Yi time limit:10000msSingle Point time limit:1000msMemory Limit:256MBDescribe

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
Algorithm Analysis: This topic is to let you draw a stroke, just through all the side once can, is about the problem of the European pull road. Simply divide the Euler path by class (based on the non-
Figure):
1). The Euler circuit: a circuit of Figure g, if it is just one time through each edge of figure g, it is called a Euler loop. (starting point, end point same)
Solution: Figure G Connect + number of points with odd degrees is 0.
2). A diagram with a Euler loop becomes a Eulerian graph.
3). Eulerian graph deformation: it can not go to the original starting point, but still have to go through all sides, is called a stroke problem.
Solution: Figure G Connect + number of points with odd degrees is 2. One is the starting point, the other is the end.
This topic mentions that: there may be multiple edges between two points, note that even if there are multiple changes, each edge must be traversed to meet the requirements. That is, as long as there is an edge, the edge
The degree of the nodes corresponding to the two endpoints will accumulate.
Code:
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include < math.h> #include <iostream> #include <string> #include <stack> #include <vector> #include <set> #include <queue> #include <algorithm> #define LL long int#define N 10000+10using namespace std ; int N, m;//1≤n≤10000 1≤m≤50000//Oralu (not a Euler loop)//Because it is not necessary to return to the starting point, so it is Oralu deformation//1) must be connected Figure 2) the number of odd points must be 2unsigned int in[n];    Vector<int>qm[n];bool vis[n];bool dfs (int u) {vis[u]=true;            for (int i=0; i<qm[u].size (); i++) {if (vis[qm[u][i]]==false) {vis[qm[u][i]]=true;        DFS (Qm[u][i]);    }}}int Main () {scanf ("%d%d", &n, &m);    int I, J;    memset (in, 0, sizeof (in));    for (i=0; i<=n; i++) qm[i].clear ();    int u, v;        for (i=0; i<m; i++) {scanf ("%d%d", &u, &v);        Qm[u].push_back (v);        Qm[v].push_back (U);        in[u]++;    in[v]++; } MemseT (Vis, false, sizeof (VIS));    DFS (1);    BOOL Flag=true;        for (I=1; i<=n; i++) {if (vis[i]==false) {flag=false;    }} int cnt=0;    for (I=1; i<=n; i++) {if (in[i]%2==1) cnt++;    } if (Flag==true && (cnt==2 | | cnt==0)) printf ("full\n");    else printf ("part\n"); return 0;}

Static array emulation:

Note: The storage edge of the array to open a bit larger, not the size of the M-bar, will re, need to open more, because it is a two-way edge.

Code:

#include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> #include < math.h> #include <iostream> #include <string> #include <algorithm> #define LL long Long int#define N 10000+100#define M 60000+100using namespace std;int N, m;//1≤n≤10000 1≤m≤50000//Oralu decision (not Euler loop)//Because it is not necessary to return to the starting point, it is the transformation of the Oralu /1) must be connected Figure 2) The number of points of odd degree must be 2unsigned int in[n];bool vis[n];int edgecnt;int head[n]={0};int p[m];int next[m]={0};void    Addedge (int u, int v) {++edgecnt;    P[edgecnt]=v;    Next[edgecnt]=head[u]; head[u]=edgecnt;}    bool Dfs (int u) {int i;            for (i=head[u]; i; I=next[i]) {if (vis[p[i]]==false) {vis[p[i]]=true;        DFS (P[i]);    }}}int Main () {scanf ("%d%d", &n, &m);    int I, J;    memset (in, 0, sizeof (in));    int u, v;    edgecnt=0;        for (i=0; i<m; i++) {scanf ("%d%d", &u, &v);        Addedge (U, v);        Addedge (V, u);        in[u]++;    in[v]++; } memset (Vis, false, sizeof (VIS));    Vis[1]=true;    DFS (1);    BOOL Flag=true;        for (I=1; i<=n; i++) {if (vis[i]==false) {flag=false;    }} int cnt=0;    for (I=1; i<=n; i++) {if (in[i]%2==1) cnt++;    } if (Flag==true && (cnt==2 | | cnt==0)) printf ("full\n");    else printf ("part\n"); return 0;}

Hiho the 49th week. Topic 1: Oralu Yi "Tuola Road Problem"

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.