Skip to content

Instantly share code, notes, and snippets.

@tice0-2
Created October 28, 2018 23:58
Show Gist options
  • Save tice0-2/2332056b5f00f5be9dd027f79fa20830 to your computer and use it in GitHub Desktop.
Save tice0-2/2332056b5f00f5be9dd027f79fa20830 to your computer and use it in GitHub Desktop.
Cases for SEERC 2017, J

Cases

Case 1, all piles are 1

take n % 3, if 0 then A loses

Case 2, only one pile > 1

A always wins

Case 3, no less than two piles > 1

If only 2 piles are left, and both != 1, then A loses.

Then the case left is that there are multiple piles with only 1 left,

  • if the number of 1-piles % 3 == 0, A loses
  • else, if there exists a pile of 2, A wins

All other cases results in A losing

#pragma comment(linker, "/STACK:1024000000,1024000000") 

#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>

using namespace std;

#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3f
#define ll long long 
#define N 100100

int n;

int ONE, TWO;

inline bool work()
{
    if (ONE == n - 1) return true;
    else if (ONE == n)
        return n % 3;
    if (ONE == n - 2)
    {
        if (n % 3 == 2) return false;
        if (TWO) return true;
        return false;
    }
    return false;
}

inline void Run()
{
    while (scanf("%d", &n) != EOF)
    {
        ONE = 0, TWO = 0;
        for (int i = 1, num; i <= n; ++i)
        {
            scanf("%d", &num);
            if (num == 1) ++ONE;
            if (num == 2) ++TWO;
        }
        puts(work() ? "Win" : "Lose");
    }
}

int main()
{
    #ifdef LOCAL
        freopen("Test.in", "r", stdin);
    #endif

    Run();
    
    return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment