"TC SRM701" partisangame (game + cycle section)

Source: Internet
Author: User

"TC SRM701" partisangame (game + follow-up link. )

Finally on a DIV1, the game time so good, think on the dozen Bai ... A dozen and fell down ... Into the reappearance, measured it, and hung a group of =.=

The loop section does not necessarily start at 0 ... Gg...

The new TC question is also not good to find the problem. = Don't know if this is the right thing to do ...

Main topic:
Loved Alice and Bob playing with stones
But the rules have changed a little.
n Block Stone (n≤109) (n \le 10^9)
Alice, taking turns, gives two arrays, indicating the number of Stones Alice and Bob can take each time to ensure that they are inside. That is, Alice and Bob can only take a number of stones in their array at a time. Unable to operate as output

Ask who wins.

Every time you take a stone, you can consider violence to find the SG function. For the condition of I stone, it can be transferred by I-5~i-1.

But n is large, and a small table can be found to have a loop.

But not necessarily starting from the beginning.

Then I have a variety of special sentences ... In fact, the larger will be a cycle, such as 1000 must be a cycle ... But..... Alas...... Hanging on a group ... Gg

Then finally the violence DP front 2000,n < 1000 words Direct output, otherwise find loops,.

The code is as follows:

#include <iostream> #include <cmath> #include <vector> #include <cstdlib> #include <cstdio > #include <cstring> #include <queue> #include <stack> #include <list> #include <algorithm 
> #include <map> #include <set> #include <vector> #define LL Long long #define PR pair<int,int> #define FREAD (CH) freopen (CH, "R", stdin) #define FWRITE (CH) freopen (CH, "w", stdout) #define CLASSNAME Partisangame using n
Amespace std;
const int INF = 0X3F3F3F3F;
const int MSZ = 10000;

Const double EPS = 1e-8;
    Class ClassName {Public:int dp[2][2333],c[2];

    BOOL VIS[10];
        string Getwinner (int n, vector <int> A, vector <int> b) {dp[0][0] = 0;

        Dp[1][0] = 0;
        int en = (n >= 1000:n);
        int en = 1000;
        Memset (C,0,sizeof (c));

        c[0]++;
            for (int i = 1; I <= en; ++i) {int id = (i <= 5? i:5);

   int TP = i;         memset (vis,0,sizeof (VIS));
                for (int j = 0; J < a.size (); ++j) {if (Id-a[j] < 0) continue;
            VIS[DP[0][TP-A[J]] = 1; } for (int j = 0;; ++j) {if (!vis[j]) {dp[1]
                    [TP] = j;
                Break
            }} memset (Vis,0,sizeof (VIS));
                for (int j = 0; J < b.size (); ++j) {if (Id-b[j] < 0) continue;
            VIS[DP[1][TP-B[J]] = 1; } for (int j = 0;; ++j) {if (!vis[j]) {dp[0]
                    [TP] = j;
                Break
        }} C[dp[1][i]? 1:0]++; } if (n <=) return dp[1][n]?
        "Alice": "Bob";
            else {if (c[1] <=) return "Bob";

   if (C[0] <=) return "Alice";         int RK = 5;

            int st = 0;
                while (1) {RK = 5;
                    for (; rk < ++RK) {bool F = 1;
                        for (int i = 0; i < RK; ++i) {if (Dp[1][st+i]! = Dp[1][st+i+rk])
                            {f = 0;
                        Break
                }} if (f) break;
                } if (RK <) break;
            st++;
            }//printf ("%d", RK); Return dp[1][(n-st)%rk+st]?
        "Alice": "Bob"; }}} Test;

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.