結果

問題 No.1315 渦巻洞穴
ユーザー KudeKude
提出日時 2020-12-12 22:10:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,475 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 81,996 KB
実行使用メモリ 99,056 KB
最終ジャッジ日時 2024-09-19 22:29:40
合計ジャッジ時間 7,269 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 73 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

s, t = map(int, input().split())

def f(n):
    if n % 2 == 1:
        ans = []
        k = 0
        while (2 * (k + 1) + 1) ** 2 <= n:
            ans.append(3)
            ans.append(0)
            k += 1
        now = (2 * k + 1) ** 2
        if now == n:
            return ans
        ans.append(0)
        ans.append(1)
        now += 2
        k += 1
        while now < n and now < (2 * k - 1) ** 2 + 2 * k - 1:
            ans.append(1)
            ans.append(1)
            now += 2
        if now == n:
            return ans
        while now < n and now < (2 * k - 1) ** 2 + 4 * k - 1:
            ans.append(2)
            ans.append(2)
            now += 2
        if now == n:
            return ans
        while now < n and now < (2 * k - 1) ** 2 + 6 * k - 1:
            ans.append(3)
            ans.append(3)
            now += 2
        if now == n:
            return ans
        while now < n:
            ans.append(0)
            ans.append(0)
            now += 2
        return ans
    else:
        ans = [3]
        k = 1
        while (2 * k - 1) ** 2 + 1 < n:
            ans.append(0)
            ans.append(3)
            k += 1
        now = (2 * k - 1) ** 2 + 1
        if now == n:
            return ans
        k -= 1
        while now > n and now > (2 * k - 1) ** 2 + 6 * k + 1:
            ans.append(2)
            ans.append(2)
            now -= 2
        if now == n:
            return ans
        ans.append(2)
        ans.append(1)
        now -= 2
        while now > n and now > (2 * k - 1) ** 2 + 4 * k + 1:
            ans.append(1)
            ans.append(1)
            now -= 2
        if now == n:
            return ans
        ans.append(1)
        ans.append(0)
        now -= 2
        while now > n and now > (2 * k - 1) ** 2 + 2 * k + 1:
            ans.append(0)
            ans.append(0)
            now -= 2
        if now == n:
            return ans
        ans.append(0)
        ans.append(3)
        now -= 2
        while now > n:
            ans.append(3)
            ans.append(3)
            now -= 2
        return ans

ps, pt = f(s), f(t)
ones = len(ps) // 2 + len(pt) // 2 + 2
ans = [(t + 2) % 4 for t in reversed(ps)]

if s % 2 == 0:
    ans.append(3)
else:
    ans.append(0)
ans.append(2)
ans.append(0)
ones += 1
if ones % 2 == 1:
    ans.append(1)
    ans.append(3)
if t % 2 == 0:
    ans.append(1)
else:
    ans.append(2)
ans += pt
print(0)
print(len(ans))
print(''.join('RULD'[a] for a in ans))
0