Problem p03245 (python)

Fixed submission:
N=int(input())

point = []
parity = {}
for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    parity[(x + y) % 2] = 1

if len(set(parity)) == 2 :
    print('-1')
else :
    m = 38
    parity = 1 if (1 in parity) else 0
    print(m + 1 - parity)
    if parity == 1 :  # 距離が奇数
        print(*[1 << i for i in range(m)])
    else :
        print(1, *[1 << i for i in range(m)])

    def arm(x, y, m) :
        if abs(x) >= abs(y) :
            if x >= 0 :
                return ('R', x - (1<<m), y)
            else :
                return ('L', x + (1<<m), y)
        else :
            if y >= 0 :
                return ('U', x, y - (1<<m))
            else :
                return ('D', x, y + (1<<m))

    for x, y in point :
        ans = []
        for i in range(m-1, -1, -1) :
            mode, x, y = arm(x, y, i)
            ans.append(mode)
        if parity == 0 :  # 偶数の場合一つ足す
            if x == 1 :
                ans.append('R')
            elif x == -1 :
                ans.append('L')
            elif y == 1 :
                ans.append('U')
            elif y == -1 :
                ans.append('D')
        print(''.join(ans[::-1]))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []
maxDist = 0

for _ in range(N) :
    x, y = map(int, input().split())
    d = abs(x) + abs(y)
    maxDist = max(maxDist, d)
    point.append((x, y, d))
    dist.append(d)

mask = maxDist % 2

for d in dist :
    if d % 2 != mask :  # 実現不可能
        print('-1')
        break
else :  # 実現可能
    print(maxDist) # 腕の数
	print(1)
    for x, y, d in point :
        if x < 0 :
            for _ in range(-x) :
                print('L', end='')
        elif x > 0 :
            for _ in range(x) :
                print('R', end='')

        if y < 0 :
            for _ in range(-y) :
                print('D', end='')
        elif y > 0 :
            for _ in range(y) :
                print('U', end='')

        R = (maxDist - d) // 2
        if R > 0 :
            for _ in range(R) :
                print('LR', end='')

        print('')

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []
maxDist = 0

for _ in range(N) :
    x, y = map(int, input().split())
    d = abs(x) + abs(y)
    maxDist = max(maxDist, d)
    point.append((x, y, d))
    dist.append(d)

mask = maxDist % 2

for d in dist :
    if d % 2 != mask :  # 実現不可能
        print('-1')
        break
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for x, y, d in point :
        if x < 0 :
            for _ in range(-x) :
                print('L', end='')
        elif x > 0 :
            for _ in range(x) :
                print('R', end='')

        if y < 0 :
            for _ in range(-y) :
                print('D', end='')
        elif y > 0 :
            for _ in range(y) :
                print('U', end='')

        R = (maxDist - d) // 2
        if R > 0 :
            for _ in range(R) :
                print('LR', end='')

        print('')

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    d = abs(x) + abs(y)
    point.append((x, y, d))
    dist.append(d)

maxDist = dist[-1]
mask = maxDist % 2

for d in dist :
    if d % 2 != mask :
        print('-1')
        break
    maxDist = max(maxDist, d)
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for x, y, d in point :
        if x < 0 :
            for _ in range(-x) :
                print('L', end='')
        elif x > 0 :
            for _ in range(x) :
                print('R', end='')

        if y < 0 :
            for _ in range(-y) :
                print('D', end='')
        elif y > 0 :
            for _ in range(y) :
                print('U', end='')

        R = (maxDist - d) // 2
        if R > 0 :
            for _ in range(R) :
                print('LR', end='')

        print('')

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    d = abs(x) + abs(y)
    point.append((x, y, d))
    dist.append(d)

maxDist = dist[-1]
mask = maxDist % 2

for d in dist :
    if d % 2 != mask :
        print('-1')
        break
    maxDist = max(maxDist, d)
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for x, y, d in point :
        if x < 0 :
            holizon = ['L'] * abs(x)
        elif x > 0 :
            holizon = ['R'] * abs(x)
        else :
            holizon = ['']

        if y < 0 :
            vertical = ['D'] * abs(y)
        elif y > 0 :
            vertical = ['U'] * abs(y)
        else :
            vertical = ['']

        R = (maxDist - d) // 2
        if R > 0 :
            last = ['LR'] * R
        else :
            last = ['']

        print(''.join(holizon + vertical + last))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    dist.append(abs(x) + abs(y))

maxDist = dist[-1]
mask = maxDist % 2

for d in dist :
    if d % 2 != mask :
        print('-1')
        break
    maxDist = max(maxDist, d)
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        # if x < 0 :
        #     holizon = ['L'] * abs(x)
        # elif x > 0 :
        #     holizon = ['R'] * abs(x)
        # else :
        #     holizon = ['']

        # if y < 0 :
        #     vertical = ['D'] * abs(y)
        # elif y > 0 :
        #     vertical = ['U'] * abs(y)
        # else :
        #     vertical = ['']

        # R = (maxDist - dist[i]) // 2
        # if R > 0 :
        #     last = ['LR'] * R
        # else :
        #     last = ['']

        # print(''.join(holizon + vertical + last))
        print('U')

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    dist.append(abs(x) + abs(y))

maxDist = dist[-1]
mask = maxDist % 2

for d in dist :
    if d % 2 != mask :
        print('-1')
        break
    maxDist = max(maxDist, d)
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        if x < 0 :
            holizon = ['L'] * abs(x)
        elif x > 0 :
            holizon = ['R'] * abs(x)
        else :
            holizon = ['']

        if y < 0 :
            vertical = ['D'] * abs(y)
        elif y > 0 :
            vertical = ['U'] * abs(y)
        else :
            vertical = ['']

        R = (maxDist - dist[i]) // 2
        if R > 0 :
            last = ['LR'] * R
        else :
            last = ['']

        print(''.join(holizon + vertical + last))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = [0] * N
dist = [0] * N
absolute = lambda x : x if x >= 0 else -x

for i in range(N) :
    x, y = map(int, input().split())
    point[i] = (x, y)
    dist[i] = absolute(x) + absolute(y)

maxDist = dist[-1]
mask = maxDist % 2

for i in range(N) :
    if dist[i] % 2 != mask :
        print('-1')
        break
    maxDist = max(maxDist, dist[i])
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        if x < 0 :
            holizon = ['L'] * absolute(x)
        elif x > 0 :
            holizon = ['R'] * absolute(x)
        else :
            holizon = ['']

        if y < 0 :
            vertical = ['D'] * absolute(y)
        elif y > 0 :
            vertical = ['U'] * absolute(y)
        else :
            vertical = ['']

        R = (maxDist - dist[i]) // 2
        if R > 0 :
            last = ['LR'] * R
        else :
            last = ['']

        print(''.join(holizon + vertical + last))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = [0] * N
dist = [0] * N
absolute = lambda x : x if x >= 0 else -x

for i in range(N) :
    x, y = map(int, input().split())
    point[i] = (x, y)
    dist[i] = absolute(x) + absolute(y)

maxDist = dist[0]
mask = maxDist % 2

for i in range(1, N) :
    if dist[i] % 2 != mask :
        break
    maxDist = max(maxDist, dist[i])
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        if x < 0 :
            holizon = ['L'] * absolute(x)
        elif x > 0 :
            holizon = ['R'] * absolute(x)
        else :
            holizon = ['']

        if y < 0 :
            vertical = ['D'] * absolute(y)
        elif y > 0 :
            vertical = ['U'] * absolute(y)
        else :
            vertical = ['']

        R = (maxDist - dist[i]) // 2
        if R > 0 :
            last = ['LR'] * R
        else :
            last = ['']

        print(''.join(holizon + vertical + last))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    dist.append(abs(x) + abs(y))

maxDist = dist[0]
mask = maxDist % 2

for i in range(1, N) :
    if dist[i] % 2 != mask :
        break
    maxDist = max(maxDist, dist[i])
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        # if x < 0 :
        #     holizon = ['L'] * abs(x)
        # elif x > 0 :
        #     holizon = ['R'] * abs(x)
        # else :
        #     holizon = ['']

        # if y < 0 :
        #     vertical = ['D'] * abs(y)
        # elif y > 0 :
        #     vertical = ['U'] * abs(y)
        # else :
        #     vertical = ['']

        # R = (maxDist - dist[i]) // 2
        # if R > 0 :
        #     last = ['LR'] * R
        # else :
        #     last = ['']
        holizon = ['']
        vertical = ['']
        last = ['']
        print(''.join(holizon + vertical + last))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    dist.append(abs(x) + abs(y))

maxDist = dist[0]
mask = maxDist % 2

for i in range(1, N) :
    if dist[i] % 2 != mask :
        break
    maxDist = max(maxDist, dist[i])
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        if x < 0 :
            holizon = ['L'] * abs(x)
        elif x > 0 :
            holizon = ['R'] * abs(x)
        else :
            holizon = ['']

        if y < 0 :
            vertical = ['D'] * abs(y)
        elif y > 0 :
            vertical = ['U'] * abs(y)
        else :
            vertical = ['']

        R = (maxDist - dist[i]) // 2
        if R > 0 :
            last = ['LR'] * R
        else :
            last = ['']
        print(''.join(holizon + vertical + last))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    dist.append(abs(x) + abs(y))

maxDist = dist[0]
mask = maxDist % 2

for i in range(1, N) :
    if dist[i] % 2 != mask :
        break
    maxDist = max(maxDist, dist[i])
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        # if x < 0 :
        #     holizon = ['L'] * abs(x)
        # elif x > 0 :
        #     holizon = ['R'] * abs(x)
        # else :
        #     holizon = ['']

        # if y < 0 :
        #     vertical = ['D'] * abs(y)
        # elif y > 0 :
        #     vertical = ['U'] * abs(y)
        # else :
        #     vertical = ['']

        holizon = ['']
        vertical = ['']

        last = ['']
        R = (maxDist - dist[i]) // 2
        if R > 0 :
            last = ['LR'] * R
        print(''.join(holizon + vertical + last))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    dist.append(abs(x) + abs(y))

maxDist = dist[0]
mask = maxDist % 2

for i in range(1, N) :
    if dist[i] % 2 != mask :
        break
    maxDist = max(maxDist, dist[i])
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        if x < 0 :
            holizon = ['L'] * abs(x)
        elif x > 0 :
            holizon = ['R'] * abs(x)
        else :
            holizon = ['']

        if y < 0 :
            vertical = ['D'] * abs(y)
        elif y > 0 :
            vertical = ['U'] * abs(y)
        else :
            vertical = ['']

        last = ['']
        R = (maxDist - dist[i]) // 2
        if R > 0 :
            last = ['LR'] * R
        print(''.join(holizon + vertical + last))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    dist.append(abs(x) + abs(y))

distSort = sorted(dist)
maxDist = distSort[-1]

for d in distSort :
    if (maxDist - d) % 2 == 1 :  # 実現不可能
        print(-1)
        break
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        if x < 0 :
            holizon = ['L'] * abs(x)
        elif x > 0 :
            holizon = ['R'] * abs(x)
        else :
            holizon = ['']

        if y < 0 :
            vertical = ['D'] * abs(y)
        elif y > 0 :
            vertical = ['U'] * abs(y)
        else :
            vertical = ['']

        last = ['']
        R = (maxDist - dist[i]) // 2
        if R > 0 :
            last = ['LR'] * R
        print(''.join(holizon + vertical + last))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    dist.append(abs(x) + abs(y))

distSort = sorted(dist)
maxDist = dist[-1]
for d in distSort :
    if (maxDist - d) % 2 == 1 :  # 実現不可能
        print(-1)
        break
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        out = ['']
        if x < 0 :
            out = ['L'] * abs(x)
        elif x > 0 :
            out = ['R'] * abs(x)
        print(''.join(out), end='')

        out = ['']
        if y < 0 :
            out = ['D'] * abs(y)
        elif y > 0 :
            out = ['U'] * abs(y)
        print(''.join(out), end = '')

        out = ['']
        R = (maxDist - dist[i]) // 2
        if R > 0 :
            out = ['LR'] * R
        print(''.join(out))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    dist.append(abs(x) + abs(y))

distSort = sorted(dist)
maxDist = dist[-1]
for d in distSort :
    if (maxDist - d) % 2 == 1 :  # 実現不可能
        print(-1)
        break
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        out = ['']
        if x < 0 :
            out = ['L'] * abs(x)
        else :
            out = ['R'] * abs(x)
        print(''.join(out), end='')
        if y < 0 :
            out = ['D'] * abs(y)
        else :
            out = ['U'] * abs(y)
        print(''.join(out), end = '')
        out = ['LR'] * ((maxDist - dist[i]) // 2)
        print(''.join(out))

Buggy submission (verdict: Runtime Error):
N = int(input())

point = []
dist = []

for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    dist.append(abs(x) + abs(y))

distSort = sorted(dist)
maxDist = dist[-1]
for d in distSort :
    if (maxDist - d) % 2 == 1 :  # 実現不可能
        print(-1)
        break
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        if x < 0 :
            out = ['L'] * abs(x)
        else :
            out = ['R'] * abs(x)
        print(''.join(out), end='')
        if y < 0 :
            out = ['D'] * abs(y)
        else :
            out = ['U'] * abs(y)
        print(''.join(out), end = '')
        out = ['LR'] * ((maxDist - dist[i]) // 2)
        print(''.join(out))