結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー 抹茶アイス抹茶アイス
提出日時 2023-07-27 14:50:43
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,773 bytes
コンパイル時間 8,365 ms
コンパイル使用メモリ 170,068 KB
実行使用メモリ 190,448 KB
最終ジャッジ日時 2024-04-15 02:28:36
合計ジャッジ時間 30,007 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
30,464 KB
testcase_01 AC 53 ms
30,336 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (87 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

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

namespace yukicoder
{
	public class Program
	{
		public static void Main()
		{
			var n = int.Parse(Console.ReadLine());
			var a = Console.ReadLine().Trim().Split(' ').Select(value => int.Parse(value)).Distinct().ToArray();
            var K = Combination.Generate(2, a.Length, true);
            var s = new List<int>();
            foreach(var k in K)
            {
                var z = 0;
                for(var i = 0; i < a.Length; i++)
                {
                    if (k[i] == 1)
                    {
                        z ^= a[i];
                    }
                }
                s.Add(z);
            }
            Console.WriteLine(s.Distinct().Count()+1);
		}
    }
    static class Combination
    {
        private static List<List<int>> _comb;
        public static List<List<int>> Generate(int n, int r, bool dupulication)
        {
            _comb = new List<List<int>>();
            CalcCombination(new List<int>(), n, r, dupulication);
            return _comb;
        }
        private static void CalcCombination(List<int> list, int n, int r, bool dupulication)
        {
            if (list.Count == r)
            {
                _comb.Add(new List<int>(list));
                return;
            }
            var index = 0;
            if (dupulication)
            {
                index = list.Any() ? list.Last() : 0;
            }
            else
            {
                index = list.Any() ? list.Last() + 1 : 0;
            }
            for (int i = index; i < n; i++)
            {
                list.Add(i);
                CalcCombination(list, n, r, dupulication);
                list.Remove(i);
            }
        }
    }
}
0