HDU 4315:climbing the Hill (ladder game)

Source: Internet
Author: User

http://acm.hdu.edu.cn/showproblem.php?pid=4315

Test instructions: There are n people to move to the coordinates of 0, they have a position a[i], of which the most close to 0 of the K-person is king, when moving in the back of the people can not cross the front of the people, first to send King to 0 of the people wins.

Idea: Ladder game. The n personal 22 pairs, forming a group, namely A[i] and A[i+1] is a group, a[i+2] and A[i+3] is a group, a[i] and a[i+1] distance as the ladder game of the odd-order value, a[i+1] and a[i+2] distance as even order (do not consider). First k=1 time to win. Even in the case, 22 adjacent is a must-fail state, because if the initiator moves in front, the hand can certainly make the situation or 22 adjacent, and then the first move the person in front of king, the hand as long as the king moved to the end. If n is odd, the a[1] goes to the end is the even number of cases. So if K is the second person and n is odd, the first person can only move to the 1 position, otherwise k can move directly to 0, so a[1] to 1.

1#include <cstdio>2#include <cstring>3 using namespacestd;4 #defineN 10105 intId[n];6 intC[n];7 8 intMain () {9     intN, K;Ten      while(SCANF ("%d%d", &n, &k)! =EOF) { One          for(inti =1; I <= N; i++) scanf ("%d", id+i); A         if(k = =1) { -Puts"Alice"); -}Else { the             intAns =0; -             if(N &1&& k = =2) id[1]--; -              for(inti =2+ (N &1); I <= N; i + =2) -Ans ^= (id[i]-id[i-1] -1); +             if(N &1) Ans ^= id[1]; -             if(ANS) puts ("Alice"); +             ElsePuts"Bob"); A         } at     } -     return 0; -}

HDU 4315:climbing the Hill (ladder 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.