Submission #3609841


Source Code Expand

def ge(k,array,ind):
    return array[ind]>=k

def lower_bound(k, array, func=ge):
    """
    k 以上を満たす最小のインデックスを返す
    もしなかったら要素数を返す
    """
    lb=-1
    ub=len(array)
    while ub-lb>1:
        mid = (lb+ub)//2
        if func(k,array,mid):
            ub=mid
        else:
            lb=mid
    return ub

def lt(k,array,ind):
    return array[ind]<k

def upper_bound(k, array, func=lt):
    """
    k 未満を満たす最大のインデックスを返す
    もしなかったら-1を返す
    """
    lb=-1
    ub=len(array)
    while ub-lb>1:
        mid = (lb+ub)//2
        if func(k,array,mid):
            lb=mid
        else:
            ub=mid
    return ub-1
def main():
    l = int(input())
    ans = []
    array = [i for i in range(60)]
    ind = upper_bound(l, array, lambda k,array,mid:2**mid<=k)
    r = array[ind]
    n = r+1
    for i in range(1,n):
        ans.append((i,i+1,0))
        ans.append((i,i+1,2**(i-1)))
    for t in range(n-1,0,-1):
        if l-2**(t-1)>=2**r:
            ans.append((t,n,l-2**(t-1)))
            l-=2**(t-1)
    print(n,len(ans))
    for f,t,c in ans:
        print(f,t,c)

if __name__ == '__main__':
    main()

Submission Info

Submission Time
Task D - All Your Paths are Different Lengths
User b1u3
Language Python (3.4.3)
Score 700
Code Size 1286 Byte
Status AC
Exec Time 21 ms
Memory 3444 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 2
AC × 22
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 21 ms 3444 KB
02.txt AC 17 ms 3064 KB
03.txt AC 17 ms 3064 KB
04.txt AC 17 ms 3064 KB
05.txt AC 18 ms 3064 KB
06.txt AC 17 ms 3064 KB
07.txt AC 17 ms 3064 KB
08.txt AC 18 ms 3064 KB
09.txt AC 18 ms 3064 KB
10.txt AC 17 ms 3064 KB
11.txt AC 17 ms 3064 KB
12.txt AC 17 ms 3064 KB
13.txt AC 17 ms 3064 KB
14.txt AC 17 ms 3064 KB
15.txt AC 17 ms 3064 KB
16.txt AC 17 ms 3064 KB
17.txt AC 17 ms 3064 KB
18.txt AC 17 ms 3064 KB
19.txt AC 17 ms 3064 KB
20.txt AC 17 ms 3064 KB
s1.txt AC 17 ms 3064 KB
s2.txt AC 17 ms 3064 KB