QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#771077#5438. Half Mixeducup-team3702#Compile Error//C++23966b2024-11-22 09:35:562024-11-22 09:36:04

Judging History

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

  • [2024-11-22 09:36:04]
  • 评测
  • [2024-11-22 09:35:56]
  • 提交

answer

def struct(n: int) -> list:
    aim = n * (n + 1) // 4 - n
    seq = []
    for i in range(n, 1, -1):
        while aim >= i * (i - 1) // 2:
            if len(seq) == 0:
                add = [0] * i
            else:
                add = [seq[-1] ^ 1] * i
            seq.extend(add)
            aim -= i * (i - 1) // 2
    leave = n - len(seq)
    if leave == n:
        leave -= 1
        seq.append(0)
    for _ in range(leave):
        seq.append(seq[-1] ^ 1)
    return seq

T = int(input())
for _ in range(T):
    n, m = map(int, input().split())
    ans = []
    if n * (n + 1) // 2 % 2 and m * (m + 1) // 2 % 2:
        print("No")
        continue
    elif m * (m + 1) // 2 % 2:
        seq = struct(n)
        for i in range(n):
            ans.append([seq[i]] * m)
    else:
        seq = struct(m)
        for _ in range(n):
            ans.append(seq)
    print("Yes")
    for i in range(n):
        print(*ans[i])

Details

answer.code:1:1: error: ‘def’ does not name a type
    1 | def struct(n: int) -> list:
      | ^~~