Submission #1093180


Source Code Expand

Copy
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;

class Myon
{
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }


    int N;
    public bool calc2(long[] A)
    {
        long sum = 0;
        for (int i = 0; i < N; i++)
        {
            sum += A[i];
        }
        if ((sum - N) % 2 == 1) return true;
        if (N % 2 == 0) return false;

        int oddcnt = 0;
        int oddpos = -1;
        for (int i = 0; i < N; i++)
        {
            if(A[i] % 2 == 1)
            {
                oddpos = i;
                oddcnt++;
            }
        }

        if (oddcnt != 1) return false;
        if (A[oddpos] == 1) return false;
        A[oddpos]--;

        while (true)
        {
            bool flag = true;
            for (int i = 0; i < N; i++)
            {
                if (A[i] % 2 != 0) flag = false;
            }
            if (!flag) break;
            for (int i = 0; i < N; i++)
            {
                A[i] /= 2;
            }
        }

        return !calc2(A);
    }

    public void calc()
    {
        long[] A;
        N = cin.nextInt();
        A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextLong();
        }
        if (calc2(A)) Console.WriteLine("First");
        else Console.WriteLine("Second");
    }
    
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Submission Info

Submission Time
Task D - Decrementing
User chokudai
Language C# (Mono 4.6.2.0)
Score 0
Code Size 2362 Byte
Status
Exec Time 123 ms
Memory 16472 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 0 / 1000 sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt
Case Name Status Exec Time Memory
in1.txt 77 ms 16344 KB
in10.txt 76 ms 16344 KB
in11.txt 91 ms 16344 KB
in12.txt 75 ms 16344 KB
in13.txt 86 ms 16344 KB
in14.txt 115 ms 16344 KB
in15.txt 84 ms 16344 KB
in16.txt 114 ms 16344 KB
in17.txt 83 ms 16344 KB
in18.txt 123 ms 16344 KB
in19.txt 85 ms 14936 KB
in2.txt 75 ms 16344 KB
in20.txt 114 ms 15320 KB
in21.txt 86 ms 16472 KB
in22.txt 78 ms 16472 KB
in23.txt 86 ms 16472 KB
in24.txt 88 ms 16472 KB
in25.txt 77 ms 16088 KB
in26.txt 100 ms 16472 KB
in27.txt 76 ms 16088 KB
in28.txt 84 ms 16472 KB
in29.txt 78 ms 16088 KB
in3.txt 75 ms 16344 KB
in30.txt 82 ms 16472 KB
in31.txt 76 ms 16344 KB
in32.txt 76 ms 16344 KB
in33.txt 78 ms 16216 KB
in34.txt 96 ms 16472 KB
in35.txt 100 ms 16344 KB
in36.txt 19 ms 2648 KB
in37.txt 19 ms 2648 KB
in4.txt 76 ms 16344 KB
in5.txt 75 ms 16344 KB
in6.txt 76 ms 16344 KB
in7.txt 75 ms 16344 KB
in8.txt 75 ms 16344 KB
in9.txt 75 ms 16344 KB
sample1.txt 19 ms 2648 KB
sample2.txt 19 ms 2648 KB
sample3.txt 20 ms 2648 KB