結果
問題 |
No.183 たのしい排他的論理和(EASY)
|
ユーザー |
|
提出日時 | 2019-09-15 14:52:04 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 960 bytes |
コンパイル時間 | 4,605 ms |
コンパイル使用メモリ | 103,424 KB |
実行使用メモリ | 178,184 KB |
最終ジャッジ日時 | 2024-07-06 22:45:32 |
合計ジャッジ時間 | 18,084 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 3 WA * 15 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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[N + 1, max + 1]; dp[0, 0] = true; for(int i = 1; i <= N; i++) { for(int j = max; j >= 0; j--) { dp[i, j] = dp[i - 1, j]; if ((j ^ a[i]) <= max) dp[i, (j ^ a[i])] |= dp[i, j]; } } int cnt = 0; for(int i = 0; i <= max; i++) { if (dp[N, i]) cnt++; } Console.WriteLine(cnt); } } }