2016 multi-school last question (HDU 5724) Chess (combined game)

Source: Internet
Author: User

The title probably said that there are n rows, 20 squares per line, there are some pieces, two people take turns to do this: Select a line to move a piece to the right of the first empty grid. Unable to carry out the loss of the person. Ask if you can win the tempo.

This game is obviously a combination of game, the initiator alternately, each decision is limited, there are victory conditions. Then the SG theorem was made. The set record set is actually t ....

#include <cstdio> #include <iostream> #include <set> using namespace std; #define L (i) i<<1 #define R (i) i<<1|1 #define INF 0x3f3f3f3f #define PI ACOs ( -1.0) #define EPS 1e-9 #define M
AXN 2000010 #define MOD 1000000007 int n,m;

int SG[MAXN];
    int main () {int t;
    Sg[0] = 0;
    SG[1] = 0;
        for (int x = 2; <= (1<<20); x + +) {int h[25] = {0};
        int pre =-1;
                    for (int i = 0; I <=; i++) {if (x& (1<<i)) {if (pre = =-1)
                Continue
                    else {int k = x-(1<<i) + (1&LT;&LT;PRE);
                H[SG[K]] = 1;
        }} else pre = i;
        } int res = 0;
        while (H[res]) res++;
    SG[X] = res;
    } scanf ("%d", &t);
        while (t--) {scanf ("%d", &n);
        int ans = 0; FoR (int i = 0; i < n; i++) {scanf ("%d", &m);
            int k = 0;
                for (int j = 0; J < m; J + +) {int x;
                scanf ("%d", &x);
            K + = (1<< (20-x));
        } ans ^= sg[k]; } printf ("%s\n", ans==0?)
    NO ":" Yes ");
} return 0; }


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.