RCO presents 日本橋ハーフマラソン 本戦

Submission #1173644

Source codeソースコード

import sys
from heapq import heapify, heappush, heappop

H, W, K, T = 30, 30, 450, 10000

def solve():
    # Input
    input()
    s, g = [], []

    for i in range(K):
        a, b, c, d = map(int, input().split())
        s.append([a - 1, b - 1])
        g.append((c - 1, d - 1))

    # Process
    res = tekito_move(s, g)
    L, ans = len(res), res

    # Output
    print(L)
    print(*ans, sep='\n')

def tekito_move(s, g):
    res = []
    ban = [[0] * W for i in range(H)]

    # 盤面を作る
    for rs, cs in s:
        ban[rs][cs] = 1

    i = 0

    for lp in range(2 * T):
        if lp == T:
            break
        if i == K:
            break

        rs, cs = s[i]
        rg, cg = g[i]
        msg = ''

        if rs < rg:
            if ban[rs + 1][cs] == 0:
                ban[rs][cs] = 0
                ban[rs + 1][cs] = 1
                s[i] = [rs + 1, cs]
                msg = '-' * i + 'D' + '-' * (K - i - 1)
        elif rs > rg:
            if ban[rs - 1][cs] == 0:
                ban[rs][cs] = 0
                ban[rs - 1][cs] = 1
                s[i] = [rs - 1, cs]
                msg = '-' * i + 'U' + '-' * (K - i - 1)
        elif cs < cg:
            if ban[rs][cs + 1] == 0:
                ban[rs][cs] = 0
                ban[rs][cs + 1] = 1
                s[i] = [rs, cs + 1]
                msg = '-' * i + 'R' + '-' * (K - i - 1)
        elif cs > cg:
            if ban[rs][cs - 1] == 0:
                ban[rs][cs] = 0
                ban[rs][cs - 1] = 1
                s[i] = [rs, cs - 1]
                msg = '-' * i + 'L' + '-' * (K - i - 1)

        if msg:
            res.append(msg)
        else:
            i += 1

    return res



def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

Submission

Task問題 B - 日本橋大渋滞
User nameユーザ名 nanae
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 2367
Source lengthソースコード長 1993 Byte
File nameファイル名
Exec time実行時間 28 ms
Memory usageメモリ使用量 3700 KB

Test case

Set

Set name Score得点 / Max score Cases
test_01 81 / 50000 subtask_01_01.txt
test_02 81 / 50000 subtask_01_02.txt
test_03 80 / 50000 subtask_01_03.txt
test_04 82 / 50000 subtask_01_04.txt
test_05 84 / 50000 subtask_01_05.txt
test_06 81 / 50000 subtask_01_06.txt
test_07 82 / 50000 subtask_01_07.txt
test_08 82 / 50000 subtask_01_08.txt
test_09 74 / 50000 subtask_01_09.txt
test_10 75 / 50000 subtask_01_10.txt
test_11 86 / 50000 subtask_01_11.txt
test_12 77 / 50000 subtask_01_12.txt
test_13 79 / 50000 subtask_01_13.txt
test_14 80 / 50000 subtask_01_14.txt
test_15 77 / 50000 subtask_01_15.txt
test_16 79 / 50000 subtask_01_16.txt
test_17 78 / 50000 subtask_01_17.txt
test_18 78 / 50000 subtask_01_18.txt
test_19 79 / 50000 subtask_01_19.txt
test_20 79 / 50000 subtask_01_20.txt
test_21 83 / 50000 subtask_01_21.txt
test_22 79 / 50000 subtask_01_22.txt
test_23 77 / 50000 subtask_01_23.txt
test_24 76 / 50000 subtask_01_24.txt
test_25 75 / 50000 subtask_01_25.txt
test_26 77 / 50000 subtask_01_26.txt
test_27 79 / 50000 subtask_01_27.txt
test_28 73 / 50000 subtask_01_28.txt
test_29 76 / 50000 subtask_01_29.txt
test_30 78 / 50000 subtask_01_30.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask_01_01.txt AC 22 ms 3700 KB
subtask_01_02.txt AC 21 ms 3572 KB
subtask_01_03.txt AC 21 ms 3700 KB
subtask_01_04.txt AC 21 ms 3572 KB
subtask_01_05.txt AC 21 ms 3700 KB
subtask_01_06.txt AC 28 ms 3572 KB
subtask_01_07.txt AC 21 ms 3572 KB
subtask_01_08.txt AC 21 ms 3700 KB
subtask_01_09.txt AC 21 ms 3700 KB
subtask_01_10.txt AC 21 ms 3700 KB
subtask_01_11.txt AC 20 ms 3572 KB
subtask_01_12.txt AC 21 ms 3700 KB
subtask_01_13.txt AC 21 ms 3572 KB
subtask_01_14.txt AC 20 ms 3572 KB
subtask_01_15.txt AC 20 ms 3572 KB
subtask_01_16.txt AC 21 ms 3700 KB
subtask_01_17.txt AC 20 ms 3572 KB
subtask_01_18.txt AC 21 ms 3700 KB
subtask_01_19.txt AC 21 ms 3700 KB
subtask_01_20.txt AC 20 ms 3572 KB
subtask_01_21.txt AC 21 ms 3572 KB
subtask_01_22.txt AC 21 ms 3572 KB
subtask_01_23.txt AC 21 ms 3700 KB
subtask_01_24.txt AC 20 ms 3700 KB
subtask_01_25.txt AC 21 ms 3700 KB
subtask_01_26.txt AC 21 ms 3700 KB
subtask_01_27.txt AC 21 ms 3572 KB
subtask_01_28.txt AC 21 ms 3700 KB
subtask_01_29.txt AC 21 ms 3700 KB
subtask_01_30.txt AC 20 ms 3572 KB