結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー yukirinyukirin
提出日時 2016-02-24 00:54:27
言語 Go
(1.21.3)
結果
AC  
実行時間 246 ms / 5,000 ms
コード長 625 bytes
コンパイル時間 15,663 ms
コンパイル使用メモリ 200,856 KB
実行使用メモリ 8,128 KB
最終ジャッジ日時 2023-09-11 23:41:33
合計ジャッジ時間 14,753 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 246 ms
8,052 KB
testcase_08 AC 196 ms
8,052 KB
testcase_09 AC 135 ms
8,064 KB
testcase_10 AC 163 ms
8,064 KB
testcase_11 AC 214 ms
8,048 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 155 ms
8,080 KB
testcase_15 AC 222 ms
8,052 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 51 ms
8,128 KB
testcase_18 AC 215 ms
8,052 KB
testcase_19 AC 27 ms
8,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	ss := make([]int, n)
	for i := range ss {
		ss[i] = nextInt()
	}

	dp := make([]bool, 1<<15+1)
	dp[0] = true

	for _, v := range ss {
		next := make([]bool, 1<<15+1)
		for k, v2 := range dp {
			if v2 {
				next[k] = true
				next[k^v] = true
			}
		}
		dp = next
	}
	sum := 0
	for _, v := range dp {
		if v {
			sum++
		}
	}
	fmt.Println(sum)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextLine())
	return i
}
0