HDU 4023 2011 Shanghai Network Competition c Greedy + simulation

Source: Internet
Author: User

Thought it was greed, and the result was not, 2333

A situation in which greed finally has an absolute advantage over himself

Point Me

1#include <cstdio>2#include <iostream>3#include <algorithm>4#include <cstring>5#include <cmath>6#include <queue>7#include <map>8 using namespacestd;9 #defineMOD 1000000007Ten Const intinf=0x3f3f3f3f; One Const Doubleeps=1e-5; AtypedefLong Longll; - #defineCL (a) memset (A,0,sizeof (a)) - #defineTS printf ("*****\n"); the Const intmaxn=1005; - intN,m,tt; - intA[MAXN]; - intMain () + { -     inti,j,k; + #ifndef Online_judge AFreopen ("1.in","R", stdin); at     #endif -scanf"%d",&TT); -     intCa=1; -      while(tt--) -     { -          for(i=1; i<= the; i++) scanf ("%d", A +i); in         intst=0, sum[5],A1,A2;//St Record the current turn to WHO, Sum[0] record is a stable steps, sum[1] recorded is a stable number of steps b - cl (sum); tosum[0]+=a[1]*2; +sum[1]+=a[2]*2; -         if(a[ the]!=0)//only one time, who first put the steady steps will be one more step the         { *             if(a[ the]%2==1) $             {Panax Notoginsengsum[0]++; -st^=1; the             } +         } Aa1=a[5]+a[6];//Good for a thea2=a[3]+a[4];//Favorable for B +         if(a1>A2) -         { $             intW=a1-A2; $sum[0]+=w/2;//A can only get half of the stable steps, B can't get anything . -             if(w%2==1) -             { the                 if(st==0) -                 {Wuyisum[0]++; the                 } -st^=1; Wu             } -         } About         Else if(a2>A1) $         { -             intw=a2-A1; -sum[1]+=w/2;//B can only get one half of the steady steps, and a can't get anything . -             if(w%2==1) A             { +                 if(st==1) the                 { -sum[1]++; $                 } thest^=1; the             } the         } thea1=a[ A]+a[ One]+a[ -]+a[ -]; -st^=a1&1;//just change the number of steps ina1=a[7]+a[8];//b is the most unfavorable, B to go more this thea2=a[9]+a[Ten];//The most detrimental to a the         if(a1>A2) About         { the             intW=a1-A2; thesum[0]+=w/2;//A can only get half of the stable steps, B can't get anything . the             if(w%2==1) +             { -                 if(st==1) the                 {Bayisum[0]++; the                 } thest^=1; -             } -         } the         Else if(a2>A1) the         { the             intw=a2-A1; thesum[1]+=w/2;//B can only get one half of the steady steps, and a can't get anything . -             if(w%2==1) the             { the                 if(st==0) the                 {94sum[1]++; the                 } thest^=1; the             }98         } Aboutprintf"Case #%d:", ca++); -         if(sum[0]==sum[1])101         {102             if(ST) puts ("Alice");103             ElsePuts"Bob");104         } the         Else if(sum[0]>sum[1])106Puts"Alice");107         ElsePuts"Bob");108     }109}

HDU 4023 2011 Shanghai Network Competition c Greedy + simulation

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.