Submit | All submissions | Best solutions | Back to list |
HS11SNTW - Social Network Existence |
Julia and Robert were just talking about their own social network which they are now working on, when someone interrupted them unexpectedly.
- "Hi, I've got my own social network too" - said Adam, who always likes to say something.
- "Really? And how many registered users do you have?
- "Only four".
- "Oh, so please tell us the structure of your network. How many friends does each of your members have? - asked Robert with some interest.
- "One member has three friends, another one has two friends and the two others have only one friend each."
- "Are you sure?"
- "Yes."
- "And if A is a friend of B, then B is also a friend of A?"
- "Yes."
Robert looked at Julia with a dose of disbelief on his face.
- "Adam is a liar" - said Julia, and neither Julia nor Robert wanted to talk to him anymore.
Over the next few days Adam was thinking how it was possible that they were so sure that he was lying. And do you know?
Given the number of members of the social network and the data about the number of friends each of them is connected to decide if such a network may exist or not.
Input
The input consists of a sequence of lines. In the first line you are given t<3000 - the number of networks to analyze. The description of each of the networks consists of two lines: in the first line you are given one number n<=200 (the number of network users) and in the second line you are given n nonnegative integers describing the number of friends of each of the network members (all of these numbers are smaller than 200).
Output
For each of the networks print in a separate line one of the two words: POSSIBLE if such a network might exist and IMPOSSIBLE in the opposite case.
Example
Input: 4 3 1 2 2 4 3 2 3 2 5 2 2 4 2 2 4 0 0 0 0 Output: IMPOSSIBLE POSSIBLE POSSIBLE POSSIBLE
Scoring
By solving this problem you score 10 points.
Added by: | kuszi |
Date: | 2011-10-15 |
Time limit: | 0.200s-0.600s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | ADA95 ASM32 BASH BF C CSHARP C++ 4.3.2 CPP C99 CLPS CLOJURE LISP sbcl LISP clisp D ERL FSHARP FORTRAN GO HASK ICON ICK JAVA JS-RHINO LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PERL6 PHP PIKE PRLG-swi PYTHON PYTHON3 RUBY SCALA SCM guile SCM qobi ST TCL WHITESPACE |
Resource: | High School Programming League (thanks to Robert Janczewski) |