QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#770529#9541. Expanding ArrayJEdwardTL 22ms10720kbPython3614b2024-11-21 22:13:432024-11-21 22:13:43

Judging History

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

  • [2024-11-21 22:13:43]
  • 评测
  • 测评结果:TL
  • 用时:22ms
  • 内存:10720kb
  • [2024-11-21 22:13:43]
  • 提交

answer

def main():
    import sys
    sys.setrecursionlimit(1 << 25)
    n, *rest = map(int, sys.stdin.read().split())
    a = rest[:n]
    
    from collections import deque

    existing = set(a)
    queue = deque(a)
    seen = set(a)
    
    while queue:
        u = queue.popleft()
        for v in a:
            if u != v:
                candidates = [u & v, u | v, u ^ v]
                for c in candidates:
                    if c not in seen:
                        seen.add(c)
                        queue.append(c)
    
    print(len(seen))

if __name__ == "__main__":
    main()

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 15ms
memory: 10592kb

input:

2
2 3

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 22ms
memory: 10720kb

input:

2
3 4

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 20ms
memory: 10652kb

input:

2
3 5

output:

8

result:

ok single line: '8'

Test #4:

score: -100
Time Limit Exceeded

input:

10
37760128 12721860 37519778 33518004 2760086 4473592 65451644 83416788 44877547 36766460

output:


result: