Submission #2326808


Source Code Expand

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private long[] A;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            A = new long[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = sc.NextLong();
            }
        }

        public void Solve()
        {
            Scan();
            long x = 0;
            foreach (long i in A)
            {
                x ^= i;
            }

            int cnt = 0;
            for (int i = 29; i >= 0; i--)
            {
                var b = 1 << i;
                foreach (var i1 in A)
                {
                    var u = i1 ^ (i1 - 1);
                    if ((x & ((u + 1) >> 1)) > 0)
                    {
                        if ((b & u) > 0)
                        {
                            x ^= u;
                            cnt++;
                            break;
                        }
                    }
                }
            }

            Console.WriteLine(x == 0 ? cnt : -1);
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Submission Info

Submission Time
Task C - Cheating Nim
User mban
Language C# (Mono 4.6.2.0)
Score 500
Code Size 2889 Byte
Status AC
Exec Time 90 ms
Memory 15824 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 26
Set Name Test Cases
Sample example0.txt, example1.txt
All 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, example0.txt, example1.txt
Case Name Status Exec Time Memory
000.txt AC 20 ms 9172 KB
001.txt AC 20 ms 9172 KB
002.txt AC 81 ms 13776 KB
003.txt AC 50 ms 13408 KB
004.txt AC 48 ms 15328 KB
005.txt AC 39 ms 15200 KB
006.txt AC 81 ms 13776 KB
007.txt AC 81 ms 13776 KB
008.txt AC 80 ms 13776 KB
009.txt AC 79 ms 15824 KB
010.txt AC 83 ms 15824 KB
011.txt AC 86 ms 15824 KB
012.txt AC 84 ms 13776 KB
013.txt AC 82 ms 13776 KB
014.txt AC 82 ms 13776 KB
015.txt AC 82 ms 13776 KB
016.txt AC 85 ms 15824 KB
017.txt AC 90 ms 13776 KB
018.txt AC 83 ms 13776 KB
019.txt AC 86 ms 15276 KB
020.txt AC 87 ms 15824 KB
021.txt AC 27 ms 11140 KB
022.txt AC 27 ms 11136 KB
023.txt AC 85 ms 15824 KB
example0.txt AC 20 ms 9044 KB
example1.txt AC 20 ms 11092 KB