Fate_O的专栏

Let’s Go!!!

hdu1536

#include <iostream>
#include <string.h>
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAXN 10000 + 10

const int INF = (~0U >> 1);

int temp[MAXN], sg[MAXN];

void getsg()
{
    sg[0] = 0;

    for (int i = 1; i <= 10000; i++)
    {
        bool vis[101];
        memset(vis, false ,sizeof(vis));

        for (int j = 0; temp[j] <= i; j++)
        {
            vis[sg[i - temp[j]]] = true;
        }

        for (int j = 0; j < 101; j++)
        {
            if (vis[j] == false)
            {
                sg[i] = j;
                break;
            }
        }
    }
}

void input()
{
    int s, n, m;

    while (cin >> s, s)
    {
        for (int i = 0; i < s; i++)
        {
            scanf("%d", &temp[i]);
        }

        sort(temp, temp + s);

        temp[s] = INF;

        getsg();

        cin >> m;

        while (m--)
        {
            cin >> n;

            int sum = 0, x;

            for (int i = 0; i < n; i++)
            {
                cin >> x;

                sum ^= sg[x];
            }

            cout << (sum ? 'W' : 'L');
        }

        cout << endl;
    }
}

int main()
{
    input();
    return 0;
}

阅读更多
个人分类: ACM->HDU
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭