2102: [Usaco2010 dec]the Trough Game

Source: Internet
Author: User

2102: [Usaco2010 dec]the trough Game time limit:10 Sec Memory limit:64 MB
submit:117 solved:84
[Submit] [Status] Descriptionfarmer John and Bessie is playing games again. This one have to does with troughs of water. Farmer John has hidden N (1 <= n <=) troughs behind the barn, and have filled some of them with food. Bessie have asked M (1 <= m <=) Questions of the form, "how many troughs from this list (which she recites) is F Illed? ". Bessie needs your help to deduce which troughs is actually filled. Consider an example with four troughs where Bessie have asked these questions (and received the indicated answers): 1) "How Many of these troughs is Filled:trough 1 "-1 trough is filled 2)" What many of these troughs is filled:troughs 2 and 3 "-1 trough is filled 3)" How many of these troughs be filled:troughs 1 and 4 "-1 trough is filled 4) "How many of these troughs is filled:troughs 3 and 4"-1 trough is filled from question 1, we know trough 1 is fil Led. From question 3, we and know trough 4 is empty. From question 4, we and know that trough 3 is fIlled. From question 2, we and know that trough 2 are empty. N-bit binary number x, so that given the number of M, to meet the X and Bi=ci, Bi Ci is read into the two number input* line 1:two space-separated integers:n and M * Lines 2..m+1:a Subs Et of troughs, specified as a sequence of contiguous N 0 ' s and 1 ' s, followed by a single integer which is the number of TRO Ughs in the specified subset is filled. output* Line 1: A single line with: * The string "impossible" if there is no possible set of filled troughs compatible wit H Farmer John ' s answers. * The string ' not UNIQUE ' if Bessie cannot determine from the given data exactly what troughs is filled. * Otherwise, a sequence of contiguous N 0 ' s and 1 ' s specifying which troughs are filled. Sample Input4 4
1000 1
0110 1
1001 1
0011 1
Sample Output1010
HINT Source

Silver

The answer: There is no other idea-only violence ... Then wrote a pure binary poor lift, and then, then, incredibly ac?!?! 44ms is also drunk = =

1 type2Point=^node;3Node=Record4 G:longint;5 Next:point;6     End;7 var8 I,j,k,l,m,n,t:longint;9A:Array[0..10000] ofPoint ;TenB,c,d:Array[0..10000] ofLongint; One C1,c2:char; A procedureAdd (x,y:longint); inline; -           varP:point; -           begin theNew (p);p ^.g:=y; -p^.next:=a[x];a[x]:=p; -           End; - procedureDFS (x:longint); inline; +           varI,j,k,l:longint;p:point; -           begin +                ifX>n Then A                   begin at                         fori:=1  toM Do ifB[i]>0  Thenexit; -                        ift=0  Then -                           begin -                                 fori:=1  toN Dod[i]:=C[i]; -t:=1; -                           End in                        Else -                            begin toWriteln ('Not UNIQUE'); + Halt; -                            End; the                   End *                Else $                    beginPanax Notoginsengp:=a[x];l:=0; -                          whileP<>Nil  Do the                               begin +                                    ifb[p^.g]=0  Then A                                       begin thel:=1; + Break ; -                                       End; $p:=P^.next; $                               End; -                         ifL=0  Then -                            begin thep:=A[x]; -                                  whileP<>Nil  DoWuyi                                       begin the Dec (b[p^.g]); -p:=P^.next; Wu                                       End; -c[x]:=1; AboutDFS (x+1); $p:=A[x]; -                                  whileP<>Nil  Do -                                       begin - Inc (B[P^.G]); Ap:=P^.next; +                                       End; the                            End; -c[x]:=0; $DFS (x+1); the                    End; the           End; the  the begin - readln (n,m); in       fori:=1  toM Doa[i]:=Nil; the       fori:=1  toM Do the          begin About                forj:=1  toN Do the                   begin the read (C1); the                        ifc1='1'  ThenAdd (j,i); +                   End; - readln (B[i]); the          End;Bayit:=0; theDfs1); theIF t=0  ThenWrite'Impossible')Else  fori:=1  toN Dowrite (d[i]); - Writeln; - Readln; the End.

2102: [Usaco2010 dec]the Trough Game

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.