Uva-10596-morning Walk (euro pull circuit!) And check the Set judgment loop)

Source: Internet
Author: User

UVA-10596

Morning Walk
Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld &%llu

Submit Status

Description

Problem H

Morning Walk

Time Limit

3 Seconds

Kamal is a motashota guy. He has got a new job in Chittagong. So, he had moved to Chittagong from Dinajpur. He is getting fatter in Dinajpur as he had no work in his hand there. So, moving to Chittagong have turned to is a blessing for him. Every morning he takes a walk through the hilly roads of charming city Chittagong. He is enjoying the city very much. There is so many roads in Chittagong and every morning he takes different paths for his walking. But while the choosing a path he makes sure he does not visit a road twice isn't even in his path back home. An intersection point of a road are not considered as the part of the road. In a sunny morning, he is thinking about what it would be if he could visit all the roads of the city in a single walk. Your task is to help Kamal in determining whether it's possible for him or not.

Input

Input would consist of several test cases. Each test case would start with a line containing the numbers. The first number indicates the number of road intersections and is denoted by N (2≤n≤200). The road intersections is assumed to being numbered from0 to N-1. The second number R denotes the number of roads (0≤r≤10000). Then there'll be is R lines each containing a numbers C1 and C2 indicating the intersections C Onnecting a road.

Output

Print a single line containing the text "Possible" without quotes if it's Possible for Kamal-visit all the RO Ads exactly once in a single walk otherwise print ' notPossible'.

Sample Input

Output for Sample Input

2 2

0 1

1 0

2 1

0 1

Possible

Not Possible

Problemsetter:muhammad Abul Hasan

International Islamic University Chittagong

Source

Root:: Competitive programming 3:the New Lower Bound of programming contests (Steven & Felix Halim):: Graph:: Spec Ial Graphs (Others):: Eulerian Graph
Root:: Competitive programming 2:this increases the lower bound of programming contests. Again (Steven & Felix Halim):: Graph:: Special Graphs (Others):: Eulerian graph

Root:: AOAPC i:beginning algorithm Contests (Rujia Liu):: Volume 2. Data Structures:: Graphs


Idea: First determine whether the diagram is connected, in judging the graph on the degree of each point is even, with DFS or BFS or and check set can be. (Blogger I did not get out of Dfs.) Think about it later)


AC Code 1:


#include <cstdio> #include <cstring> #include <algorithm>using namespace std;const int maxv = 205;int Deg[maxv];int fa[maxv];int Find (int x) {if (x! = Fa[x]) fa[x] = find (fa[x]); return fa[x];} int main () {int n, r;while (scanf ("%d%d", &n, &r)!=eof) {if (r = = 0) {printf ("not possible\n"); continue;}  





Uva-10596-morning Walk (euro pull circuit!) And check the Set judgment loop)

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.