F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

How many people have ipad II

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 342    Accepted Submission(s): 149


Problem Description
hh found more and more of his friends are having ipad IIs. One day when they get together, hh asked his five friends, "How many of you have ipad II now?"

"One!"
"Three!"
"Everyone!"
"Four!"
"Two!"

hh's friends knew each other. They were clear about the "how many" question, while the answers are different, so there must be some people telling lies.

One of hh's friends told him(hh):
number of people, who had ipad IIs, and lied, was no more than 1.
number of people, who didn't have ipad IIs, and told the truth, was no more than 2.
at least one people have ipad II.

Given the information, hh realized there may be one or two people having ipad IIs.

Now hh asks N people the "how many" question. These N friends answer one by one. Some tell the truth, some lie. What hh knows is:
1.number of people, who have ipad IIs, and lie, is no more than A.
2.number of people, who don't have ipad IIs, and tell the truth, is no more than B.
3.At least one people have ipad II.

How many ipad IIs do these N people have?
 

Input
The input begins with an integer T(1<=T<=100).
The next T blocks each indicates a case.
The first line of each case contain a number N(1<=N<=16) then N positive integers follow, integers won't be lager than N.
Then following two numbers A , B(0 <= A,B <= N).
 

Output
Output the number of people have ipad II.
There may be many answers, output them by increasing order. (separated by space)
Output "impossible" if that's impossible.
 

Sample Input
3 5 1 2 3 4 5 1 2 3 0 0 0 1 1 4 0 0 0 0 0 1
 

Sample Output
1 2 1 impossible
 

Author
NotOnlySuccess
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-07 00:52:31, Gzip enabled