結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー k3079k
提出日時 2019-09-15 15:08:51
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 770 ms / 5,000 ms
コード長 892 bytes
コンパイル時間 3,497 ms
コンパイル使用メモリ 108,256 KB
実行使用メモリ 26,184 KB
最終ジャッジ日時 2024-07-02 17:20:50
合計ジャッジ時間 10,563 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

namespace Test01
{
    class Program
    {
        
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int[] a = new int[N + 1];
            for (int i = 1; i <= N; i++) a[i] = int.Parse(input[i - 1]);

            int max = 32767;
            bool[] dp = new bool[max + 1];
            dp[0] = true;
            for(int i = 1; i <= N; i++)
            {
                for(int j = 0; j <= max; j++)
                {
                    if ((j ^ a[i]) <= max) dp[j ^ a[i]] |= dp[j];
                }
            }

            int cnt = 0;
            for(int j = 0; j <= max; j++)
            {
                if (dp[j]) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}
0