結果

問題 No.184 たのしい排他的論理和(HARD)
ユーザー 紙ぺーぱー紙ぺーぱー
提出日時 2015-04-07 02:08:00
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 1,589 bytes
コンパイル時間 3,629 ms
コンパイル使用メモリ 106,404 KB
実行使用メモリ 43,396 KB
最終ジャッジ日時 2023-09-17 16:15:55
合計ジャッジ時間 7,291 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
22,480 KB
testcase_01 AC 61 ms
22,492 KB
testcase_02 RE -
testcase_03 AC 63 ms
24,572 KB
testcase_04 AC 182 ms
24,520 KB
testcase_05 WA -
testcase_06 AC 61 ms
24,416 KB
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 60 ms
22,480 KB
testcase_20 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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<long>();
            for (int i = 0; i < 1<<n; i++)
            {
                long 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 long[] 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 long[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