QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#711971#6408. Classical Counting ProblemdejianCompile Error//C++141.3kb2024-11-05 14:10:342024-11-05 14:10:34

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 14:10:34]
  • 评测
  • [2024-11-05 14:10:34]
  • 提交

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’