結果

問題 No.1315 渦巻洞穴
ユーザー trineutrontrineutron
提出日時 2020-12-12 16:53:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,060 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 11,996 KB
実行使用メモリ 10,688 KB
最終ジャッジ日時 2023-10-20 02:08:58
合計ジャッジ時間 6,999 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,280 KB
testcase_01 AC 29 ms
10,280 KB
testcase_02 WA -
testcase_03 AC 30 ms
10,280 KB
testcase_04 AC 30 ms
10,280 KB
testcase_05 AC 29 ms
10,280 KB
testcase_06 AC 29 ms
10,280 KB
testcase_07 AC 29 ms
10,280 KB
testcase_08 AC 30 ms
10,280 KB
testcase_09 WA -
testcase_10 AC 29 ms
10,280 KB
testcase_11 WA -
testcase_12 AC 29 ms
10,280 KB
testcase_13 AC 38 ms
10,460 KB
testcase_14 AC 35 ms
10,416 KB
testcase_15 AC 32 ms
10,340 KB
testcase_16 AC 36 ms
10,432 KB
testcase_17 AC 36 ms
10,424 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 39 ms
10,472 KB
testcase_21 AC 38 ms
10,440 KB
testcase_22 AC 39 ms
10,420 KB
testcase_23 WA -
testcase_24 AC 32 ms
10,312 KB
testcase_25 AC 40 ms
10,572 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 43 ms
10,580 KB
testcase_30 AC 40 ms
10,532 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 41 ms
10,576 KB
testcase_34 WA -
testcase_35 AC 40 ms
10,472 KB
testcase_36 AC 38 ms
10,444 KB
testcase_37 AC 33 ms
10,360 KB
testcase_38 AC 38 ms
10,432 KB
testcase_39 AC 40 ms
10,524 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 43 ms
10,624 KB
testcase_43 WA -
testcase_44 AC 44 ms
10,624 KB
testcase_45 AC 44 ms
10,688 KB
testcase_46 AC 44 ms
10,624 KB
testcase_47 WA -
testcase_48 AC 45 ms
10,624 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 44 ms
10,624 KB
testcase_52 WA -
testcase_53 AC 44 ms
10,624 KB
testcase_54 AC 45 ms
10,688 KB
testcase_55 AC 44 ms
10,624 KB
testcase_56 WA -
testcase_57 AC 45 ms
10,624 KB
testcase_58 WA -
testcase_59 AC 37 ms
10,436 KB
testcase_60 AC 37 ms
10,436 KB
testcase_61 AC 37 ms
10,436 KB
testcase_62 AC 37 ms
10,440 KB
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 AC 37 ms
10,436 KB
testcase_67 AC 37 ms
10,440 KB
testcase_68 AC 37 ms
10,440 KB
testcase_69 AC 38 ms
10,436 KB
testcase_70 AC 38 ms
10,440 KB
testcase_71 WA -
testcase_72 AC 37 ms
10,436 KB
testcase_73 WA -
testcase_74 WA -
testcase_75 AC 33 ms
10,280 KB
testcase_76 AC 31 ms
10,280 KB
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 AC 40 ms
10,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def pos(n):
    if n == 1:
        return 0, 0
    layer = int((math.sqrt(n) - 1) / 2)
    while (2 * layer + 1) ** 2 < n:
        layer += 1
    offset = (2 * layer - 1) ** 2
    edge = 2 * layer
    diff = n - offset - 1
    q, r = divmod(diff, edge)
    r += 1
    if q == 0:
        return layer, -layer + r
    elif q == 1:
        return layer - r, layer
    elif q == 2:
        return -layer, layer - r
    else:
        return -layer + r, -layer

def move(x, y):
    rev = {'L': 'R', 'R': 'L', 'U': 'D', 'D': 'U'}
    s = max(x, 0) * 'R' + max(-x, 0) * 'L' + max(y, 0) * 'U' + max(-y, 0) * 'D'
    res = ''
    for i in range(0, len(s) - 1, 2):
        res += s[i] + rev[s[i]] + s[i] + s[i + 1]
    if len(s) % 2:
        res += s[-1] + rev[s[-1]] + s[-1]
    return res

def move_rev(x, y):
    return move(x, y)[::-1]

s, t = map(int, input().split())
x0, y0 = pos(s)
x1, y1 = pos(t)
if (s + t) % 2 == 0:
    ans = move(-x0, -y0) + 'RUL' + move_rev(x1, y1 - 1)
else:
    ans = move(x1 - x0, y1 - y0)
print(0)
print(len(ans))
print(ans)
0