hihoCoder-1176-Oralu Yi (Judge of Oralu)

Source: Internet
Author: User
Tags in degrees

#1176: Oralu Yi time limit:10000msSingle Point time limit:1000msMemory 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".

Sample input
6 81 21 42 42 52 33 64 55 6
Sample output
Full



Oralu's decision: an undirected graph exists Oralu when and only if the graph is connected and there are only 2 points in degrees that are odd, at which point the two points can only serve as the starting and ending points of the Euler path.


To be concise is to judge the entrance and exit degree + and check the number of connected components.


AC Code:

#include <map> #include <set> #include <cmath> #include <deque> #include <queue> #include <stack> #include <cstdio> #include <cctype> #include <string> #include <vector> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> #define LL long long# Define INF 0x7fffffffusing namespace Std;int n, m;const int maxn = 10005;vector<int> g[maxn];int pa[maxn];int deg[ma Xn];int vis[maxn];int Find (int x) {return pa[x] = = x X:pa[x] = find (Pa[x]);} int main () {while (scanf ("%d%d", &n, &m)! = EOF) {memset (Vis, 0, sizeof (VIS)); for (int i = 0; I <= n; i + +) {pa[ I] = i;} for (int i = 0; i < m; i + +) {int u, v;scanf ("%d%d", &u, &v); int fu = find (u); int fv = find (v); if (fu! = FV) pa[ FU] = fv;deg[u] + +;d Eg[v] + +;} int flag = 1;//Determines how many points have a degree of odd int cnt = 0;for (int i = 1; I <= n; i + +) {if (Deg[i] & 1) {cnt + +;}} if (! ( CNT = = 0 | | CNT = = 2)) {flag = 0;} And check the set to determine the connected component CNT = 0;for (int i = 1; I <= N; i + +) {int f = find (i); if (!vis[f]) {cnt ++;vis[f] = 1;}} if (cnt! = 1) flag = 0;if (flag = = 1) {printf ("full\n");} else {printf ("part\n");}} return 0;}












Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

hihoCoder-1176-Oralu Yi (Judge of Oralu)

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.