Last active
June 4, 2021 00:58
-
-
Save magurofly/9ff8afbc130cab58920ee68c5757d7d9 to your computer and use it in GitHub Desktop.
典型057
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 提出: https://atcoder.jp/contests/typical90/submissions/23159483 | |
# 入力 | |
N, M = gets.split.map(&:to_i) | |
A = Array.new(N) { gets; gets.split.map(&:to_i) } | |
S = gets.split.map(&:to_i) | |
# 行ベクトルの配列 | |
xs = A.map { |indices| | |
x = 0 | |
indices.each do |index| | |
x |= 1 << index - 1 | |
end | |
x | |
} | |
# 基底を求める | |
bases = [] | |
xs.each do |x| | |
bases.each do |base| | |
x = [x, x ^ base].min | |
end | |
bases << x if x != 0 | |
end | |
# 解く | |
y = S.join.reverse.to_i(2) | |
bases.each do |base| | |
y = [y, y ^ base].min | |
end | |
if y != 0 | |
puts 0 | |
exit | |
end | |
rank = bases.size | |
puts 2.pow(N - rank, 998244353) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment