Submission #1037931


Source Code Expand

ans = []
def f(k, x, y, t):
    assert x<y if t else x>y
    if k == 0:
        ans.append("%d %d" % (x, y))
        #ans.append((x, y))
        return
    a = 2**(k-1)
    if t:
        f(k-1, x+a, y+a+1, t)
        ans.append("%d %d" % (x, y))
        f(k-1, x, y+1, t)
    else:
        f(k-1, x+a+1, y+a, t)
        ans.append("%d %d" % (x, y))
        f(k-1, x+1, y, t)
    #ans.append((x, y))
N = 11
f(N-1, 0, 1, 1)
ans.append("%d %d" % (0, 0))
f(N-1, 1, 0, 0)
#ans.append((0, 0))
print "\n".join(ans)

Submission Info

Submission Time
Task B - Binary Tree
User sugopurochakku
Language Python (2.7.6)
Score 24
Code Size 529 Byte
Status AC
Exec Time 25 ms
Memory 2948 KB

Judge Result

Set Name All
Score / Max Score 24 / 100
Status
AC × 1
Set Name Test Cases
All 1.txt
Case Name Status Exec Time Memory
1.txt AC 25 ms 2948 KB