QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#711971 | #6408. Classical Counting Problem | dejian | Compile Error | / | / | C++14 | 1.3kb | 2024-11-05 14:10:34 | 2024-11-05 14:10:34 |
Judging History
answer
import sys
import math
import threading
def main():
import sys
MOD = 998244353
t = int(sys.stdin.readline())
for _ in range(t):
line = ''
while line.strip() == '':
line = sys.stdin.readline()
n,m,v = map(int,line.strip().split())
a = []
while len(a) < n:
a += list(map(int, sys.stdin.readline().strip().split()))
# For each j, compute C_j = set of i where a_i >= a_j -m
C = []
for j in range(n):
req = a[j] - m
if req <0:
req = -math.inf
Cj = 0
for i in range(n):
if a[i] >= a[j] - m:
Cj |= (1 << i)
C.append(Cj)
# Now, need to count subsets S where for all j not in S, S intersects C_j !=0
# If n >20, it's impossible to iterate. Hence, n<=20
if n >20:
print(0)
continue
total =0
for S in range(1,1<<n):
valid = True
for j in range(n):
if not (S & (1 << j)):
if (S & C[j]) ==0:
valid = False
break
if valid:
total = (total +1)%MOD
print(total%MOD)
threading.Thread(target=main,).start()
详细
answer.code:10:16: error: empty character constant 10 | line = '' | ^~ answer.code:11:31: error: empty character constant 11 | while line.strip() == '': | ^~ answer.code:17:11: error: invalid preprocessing directive #For 17 | # For each j, compute C_j = set of i where a_i >= a_j -m | ^~~ answer.code:28:11: error: invalid preprocessing directive #Now 28 | # Now, need to count subsets S where for all j not in S, S intersects C_j !=0 | ^~~ answer.code:29:11: error: invalid preprocessing directive #If; did you mean #if? 29 | # If n >20, it's impossible to iterate. Hence, n<=20 | ^~ | if answer.code:29:23: warning: missing terminating ' character 29 | # If n >20, it's impossible to iterate. Hence, n<=20 | ^ answer.code:1:1: error: ‘import’ does not name a type 1 | import sys | ^~~~~~ answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’