HDU 4023 (game greedy simulation) game

Source: Internet
Author: User

If hard to say that this is a game problem, then this game is unfair game (Partizan games), because the two sides face the same situation to make the decision is not the same.

We usually do games are fair game (impartial games), so in this problem, those who win will be defeated, the SG function of the SG theorem is not useful.

However, this problem can be greedy.

For example, the first pattern was safe and stable for Alice, because Bob would not go with him, so Alice could save the last place. In the same way, Bob can save the 2nd pattern to the end of the release.

For example, the 15th pattern, if the first to occupy the words will be very cost-effective, because if one side accounted for, not only the other side can not put, he will be more a stable bit.

For more detailed analysis see this: http://www.cnblogs.com/staginner/archive/2011/09/10/2173317.html

I find that everyone's thinking is based on this.

1#include <cstdio>2 3 inta[ -];4 5 intMain ()6 {7     //freopen ("In.txt", "R", stdin);8 9     intT scanf"%d", &T);Ten      for(intKase =1; Kase <= T; ++Kase) One     { A          for(inti =1; I <= the; i++) scanf ("%d", &a[i]); -         intnow =0, A = a[1] *2, B = a[2] *2; -         if(a[ the] %2!=0) {a++; now =1; } the         intTA = a[5] + a[6], TB = a[3] + a[4]; -         if(Ta > TB)//Alice Rob 5,6, Bob Rob 3,4 -         { -Ta-=TB; +             if(Ta%2!=0) -             { +                 if(now = =0) A + = ta/2+1; A                 ElseA + = TA/2; atnow =1-Now ; -             } -             ElseA + = TA/2; -         } -         Else if(Ta <TB) -         { inTB-=ta; -             if(TB%2!=0) to             { +                 if(now = =0) B + = TB/2; -                 ElseB + = TB2+1; thenow =1-Now ; *             } $             ElseB + = TB/2;Panax Notoginseng         } -         //two people divide 11,12,13,14 the         intt = a[ One] + a[ A] + a[ -] + a[ -]; +         if(t%2!=0) now =1-Now ; A         //Alice Rob 7,8, Bob Rob 9,10 theTA = a[7] + a[8]; TB = a[9] + a[Ten]; +         if(Ta <TB) -         { $TB-=ta; $             if(TB%2!=0) -             { -                 if(now = =0) B + = TB2+1; the                 ElseB + = TB/2; -now =1-Now ;Wuyi             } the             ElseB + = TB/2; -         } Wu         Else if(Ta >TB) -         { AboutTa-=TB; $             if(Ta%2!=0) -             { -                 if(now = =0) A + = TA/2; -                 ElseA + = ta/2+1; Anow =1-Now ; +             } the             ElseA + = TA/2; -         } $  the         BOOLwin; the         if(now = =0) win = B >= A?false:true; the         ElseWin = A >= B?true:false; theprintf"Case #%d:%s\n", Kase, Win?"Alice":"Bob"); -     } in  the     return 0; the}
code June

HDU 4023 (game greedy simulation) 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.