結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー 紙ぺーぱー紙ぺーぱー
提出日時 2015-04-07 02:05:50
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,585 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 106,308 KB
実行使用メモリ 26,996 KB
最終ジャッジ日時 2023-09-17 06:23:12
合計ジャッジ時間 4,868 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
22,584 KB
testcase_01 AC 62 ms
22,508 KB
testcase_02 AC 62 ms
24,536 KB
testcase_03 AC 61 ms
22,400 KB
testcase_04 AC 62 ms
22,412 KB
testcase_05 AC 63 ms
22,412 KB
testcase_06 AC 61 ms
22,452 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 67 ms
22,968 KB
testcase_13 AC 60 ms
22,496 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 62 ms
22,392 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

static public class Program
{
    static public void Main()
    {
        var n = readInteger();
        var a = readLong(n, ' ');
        if(n<=20)
        {
            var set = new HashSet<int>();
            for (int i = 0; i < 1<<n; i++)
            {
                var x = 0;
                for (int j = 0; j < n; j++)
                    if (((i >> j) & 1) == 1) x ^= a[j];
                set.Add(x);
            }
            Console.WriteLine(set.Count);
        }
    }

    static int readInteger()
    {
        var s = Console.ReadLine();
        return int.Parse(s);
    }
    static int[] readLong(int n, params char[] sep)
    {
        var s = Console.ReadLine().Split(sep);
        if (s.Length != n)
            throw new Exception(string.Format("invalid input, expected{0} actual{1}", n, s.Length));
        var ret = new int[n];
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(s[i]);
        return ret;
    }
    static void readEOF()
    {
        if (Console.In.Peek() >= 0)
            throw new Exception("invalid input too long input file");
    }

}
static public class Ex
{
    static public T Validate<T>(this T input, Func<T, bool> f)
    {
        if (!f(input))
            throw new Exception("invalid input");
        return input;
    }
    static public T[] ValidateArray<T>(this T[] input, Func<T, bool> f)
    {
        foreach (var x in input)
            if (!f(x))
                throw new Exception("invalid input");
        return input;
    }
}


0