結果
問題 | No.183 たのしい排他的論理和(EASY) |
ユーザー | 紙ぺーぱー |
提出日時 | 2015-04-06 20:08:06 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 727 ms / 5,000 ms |
コード長 | 1,694 bytes |
コンパイル時間 | 3,520 ms |
コンパイル使用メモリ | 104,948 KB |
実行使用メモリ | 46,156 KB |
最終ジャッジ日時 | 2023-09-11 10:58:40 |
合計ジャッジ時間 | 10,361 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 61 ms
21,460 KB |
testcase_01 | AC | 64 ms
23,432 KB |
testcase_02 | AC | 63 ms
21,324 KB |
testcase_03 | AC | 62 ms
21,468 KB |
testcase_04 | AC | 61 ms
21,380 KB |
testcase_05 | AC | 63 ms
23,444 KB |
testcase_06 | AC | 62 ms
23,468 KB |
testcase_07 | AC | 727 ms
41,988 KB |
testcase_08 | AC | 582 ms
42,068 KB |
testcase_09 | AC | 421 ms
42,032 KB |
testcase_10 | AC | 494 ms
44,024 KB |
testcase_11 | AC | 625 ms
43,816 KB |
testcase_12 | AC | 64 ms
19,400 KB |
testcase_13 | AC | 61 ms
23,592 KB |
testcase_14 | AC | 460 ms
40,140 KB |
testcase_15 | AC | 646 ms
43,916 KB |
testcase_16 | AC | 63 ms
21,532 KB |
testcase_17 | AC | 199 ms
41,872 KB |
testcase_18 | AC | 650 ms
46,156 KB |
testcase_19 | AC | 134 ms
41,516 KB |
コンパイルメッセージ
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; static public class Program { static public void Main() { var n = readInteger().Validate(x => 1 <= x && x <= 5000); var a = readInteger(n).ValidateArray(x => 1 <= x && x <= 16384); readEOF(); var dp = new bool[32768]; dp[0] = true; foreach (var x in a) { var next = new bool[32768]; for (int i = 0; i < dp.Length; i++) if (dp[i]) next[i] = next[i ^ x] = true; dp = next; } var cnt = dp.Count(x => x); Console.WriteLine(cnt); } static int readInteger() { var s = Console.ReadLine(); return int.Parse(s); } static int[] readInteger(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; } }