12742 - Guess the gender   

Description

There is a game called "Guess the Gender",
the game rule is that given the number of people N and M hints,
a hint will be given as a pair of people's index,
represent that their genders are different,
in other words, a male and a female.

Your mission is to tell that if the given information is correct or not.

This is a partial judge problem,
and the problem is for exercising OOP,
so please use the given code to finish the problem,
and choose c++11 as the language on submission.
Since the code is using 'nullptr' instead of 'NULL', but you can just see 'nullptr' as 'NULL', they are kind of same.

To compile as c++11,
for those using codeblocks: `settings -> global compiler settings -> compiler flags -> check the option with [-std=c++11]`,
for those using devcpp: `Tools -> Compiler Options -> check 'Add the following commands when calling the compiler' -> add '-std=c++11'
for those using the command: `g++ -std=c++11 your_file.cpp`

ouo.

For Sample Input 1,
3 3
0 1
1 2
2 0
If person 0 is male, the first hint infers that person 1 is a female, then the second hint infer that person 2 is a male, but then the third hint contradicts.
If the person 0 is a female, it is not possible too.
So the answer should be "Not Possible".

4/26 supplement:
If you still have trouble in this problem after reading description and tracing codes, we show each step in the 
link, maybe it will be helpful for you :)

Input

The first line contains 2 numbers N, M,
N is the number of people and M is the number of hints.

Then the next M lines, each line contains 2 numbers X, Y,
represent the Xth person and Yth person have different gender.
The index starts at 0.

It is a guarantee that:
1 <= N <= 10^5,
1 <= M <= 10^6,

0 <= X, Y < N

Output

The output should be "Possible" if the given hint is correct,
or "Not Possible" if the given hint is not correct. (Without quotes)

Remember to add a newline character after the output.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12742.cpp

Partial Judge Header

12742.h

Tags




Discuss