Submission #54414039
Source Code Expand
Copy
# 30 行目(オリジナルの 27 行目)だけ改変しました。# https://atcoder.jp/contests/arc179/submissions/54319004$debug = !ARGV[0].nil?M, N = STDIN.gets.chomp.split.map(&:to_i)XS = STDIN.gets.chomp.split.map(&:to_i)R = 998244353rxs = Array.new(M, 0)XS.each.with_index do |x, i|rxs[x - 1] += (1 << i)end$n_2_n2_r = Array.new(1 << M) { [] }(1 << M).times do |n|n.digits(2).each.with_index do |d, i|next if d == 0n2 = n & ~(1 << i) | rxs[i]$n_2_n2_r[n2] << n
# 30 行目(オリジナルの 27 行目)だけ改変しました。 # https://atcoder.jp/contests/arc179/submissions/54319004 $debug = !ARGV[0].nil? M, N = STDIN.gets.chomp.split.map(&:to_i) XS = STDIN.gets.chomp.split.map(&:to_i) R = 998244353 rxs = Array.new(M, 0) XS.each.with_index do |x, i| rxs[x - 1] += (1 << i) end $n_2_n2_r = Array.new(1 << M) { [] } (1 << M).times do |n| n.digits(2).each.with_index do |d, i| next if d == 0 n2 = n & ~(1 << i) | rxs[i] $n_2_n2_r[n2] << n end end def count dp = Array.new(1 << M, 0) dp[(1 << M) - 1] = 1 # first status N.times do |i| dp = $n_2_n2_r.map { |ns| dp.values_at(*ns).sum } if i % 8 == 0 dp = dp.map { |d| d % R } end end dp.sum % R end puts count
Submission Info
Submission Time | |
---|---|
Task | B - Between B and B |
User | ds14050 |
Language | Ruby (ruby 3.2.2) |
Score | 500 |
Code Size | 796 Byte |
Status | AC |
Exec Time | 1628 ms |
Memory | 19056 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt |
All | 00-sample-001.txt, 00-sample-002.txt, 00-sample-003.txt, 01-handmade-001.txt, 01-handmade-002.txt, 01-handmade-003.txt, 01-handmade-004.txt, 01-handmade-005.txt, 01-handmade-006.txt, 01-handmade-007.txt, 01-handmade-008.txt, 01-handmade-009.txt, 02-random-001.txt, 02-random-002.txt, 02-random-003.txt, 02-random-004.txt, 02-random-005.txt, 02-random-006.txt, 02-random-007.txt, 02-random-008.txt, 02-random-009.txt, 02-random-010.txt, 02-random-011.txt, 02-random-012.txt, 02-random-013.txt, 02-random-014.txt, 02-random-015.txt, 02-random-016.txt, 02-random-017.txt, 02-random-018.txt, 02-random-019.txt, 02-random-020.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00-sample-001.txt | AC | 119 ms | 17252 KB |
00-sample-002.txt | AC | 44 ms | 17000 KB |
00-sample-003.txt | AC | 43 ms | 17404 KB |
01-handmade-001.txt | AC | 43 ms | 17196 KB |
01-handmade-002.txt | AC | 47 ms | 17432 KB |
01-handmade-003.txt | AC | 1610 ms | 19056 KB |
01-handmade-004.txt | AC | 1599 ms | 18324 KB |
01-handmade-005.txt | AC | 1565 ms | 18392 KB |
01-handmade-006.txt | AC | 1628 ms | 18584 KB |
01-handmade-007.txt | AC | 1610 ms | 18340 KB |
01-handmade-008.txt | AC | 1628 ms | 18744 KB |
01-handmade-009.txt | AC | 45 ms | 17488 KB |
02-random-001.txt | AC | 44 ms | 17260 KB |
02-random-002.txt | AC | 44 ms | 17420 KB |
02-random-003.txt | AC | 44 ms | 17180 KB |
02-random-004.txt | AC | 43 ms | 17244 KB |
02-random-005.txt | AC | 45 ms | 17484 KB |
02-random-006.txt | AC | 44 ms | 17320 KB |
02-random-007.txt | AC | 45 ms | 17112 KB |
02-random-008.txt | AC | 62 ms | 18244 KB |
02-random-009.txt | AC | 49 ms | 18036 KB |
02-random-010.txt | AC | 43 ms | 17200 KB |
02-random-011.txt | AC | 46 ms | 17060 KB |
02-random-012.txt | AC | 44 ms | 17436 KB |
02-random-013.txt | AC | 583 ms | 18200 KB |
02-random-014.txt | AC | 216 ms | 17936 KB |
02-random-015.txt | AC | 47 ms | 17252 KB |
02-random-016.txt | AC | 220 ms | 18088 KB |
02-random-017.txt | AC | 53 ms | 17576 KB |
02-random-018.txt | AC | 52 ms | 17276 KB |
02-random-019.txt | AC | 61 ms | 17912 KB |
02-random-020.txt | AC | 48 ms | 17320 KB |