Submission #2236241


Source Code Expand

Copy
from collections import deque
# coding: UTF-8
#@document_it
def document_it(func):
def new_function(*args,**kwargs):
print('Running function:', func.__name__)
print('Positional arguments:', args)
print('Kewword arguments:', kwargs)
result = func(*args,**kwargs)
print('Result:', result)
return result
return new_function
def exe():
n,y = map(int,input().split())
p,q,r = solve(n,y)
print(str(p)+" "+str(q)+" "+str(r))
def solve(n,y):
ys = y//1000
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
from collections import deque
# coding: UTF-8
#@document_it

def document_it(func):
    def new_function(*args,**kwargs):
        print('Running function:', func.__name__)
        print('Positional arguments:', args)
        print('Kewword arguments:', kwargs)
        result = func(*args,**kwargs)
        print('Result:', result)
        return result
    return new_function

def exe():
    n,y = map(int,input().split())
    p,q,r = solve(n,y)
    print(str(p)+" "+str(q)+" "+str(r))
    
def solve(n,y):
    ys = y//1000
    vstart = (0,0,ys)
    checked = set()
    depth = {}
    queue = deque()
    ###
    w = vstart
    depth[w] = 0
    if maisuu(w) == n:
        return w
    queue.appendleft(w)
    checked.add(w)
    while queue:
        v = queue.pop()
        neighbors = neighbor(v)
        for w in neighbors:
            if w in checked:
                continue
            if maisuu(w) == n:
                return w
            else:
                queue.appendleft(w)
                checked.add(w)
    return (-1,-1,-1)

def maisuu(v):
    p,q,r = v
    return p + q + r
def neighbor(v):
    p,q,r = v
    ans = []
    if r >= 5:
        ans.append((p,q+1,r-5))
    if r >= 10:
        ans.append((p+1,q,r-10))
    if q >= 2:
        ans.append((p+1,q-2,r))
    return ans

if __name__ == '__main__':
    exe()

Submission Info

Submission Time
Task ABC085C - Otoshidama
User moriiforfun
Language Python (3.4.3)
Score 0
Code Size 1396 Byte
Status TLE
Exec Time 2113 ms
Memory 181324 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
TLE × 1
AC × 16
TLE × 8
Set Name Test Cases
Sample a01, a02, a03, a04
All a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Case Name Status Exec Time Memory
a01 AC 20 ms 3316 KB
a02 AC 21 ms 3444 KB
a03 AC 21 ms 3444 KB
a04 TLE 2113 ms 179404 KB
b05 AC 20 ms 3316 KB
b06 AC 20 ms 3316 KB
b07 AC 20 ms 3316 KB
b08 AC 21 ms 3316 KB
b09 TLE 2113 ms 181324 KB
b10 AC 92 ms 9196 KB
b11 TLE 2112 ms 176204 KB
b12 AC 20 ms 3316 KB
b13 AC 20 ms 3316 KB
b14 AC 21 ms 3316 KB
b15 TLE 2113 ms 180172 KB
b16 TLE 2111 ms 173772 KB
b17 TLE 2113 ms 177356 KB
b18 AC 21 ms 3316 KB
b19 AC 36 ms 4720 KB
b20 AC 425 ms 36052 KB
b21 AC 89 ms 9324 KB
b22 AC 89 ms 9068 KB
b23 TLE 2112 ms 175656 KB
b24 TLE 2113 ms 178636 KB


2025-04-15 (Tue)
22:04:37 +00:00