結果

問題 No.232 めぐるはめぐる (2)
ユーザー rpy3cpprpy3cpp
提出日時 2015-06-26 23:17:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 990 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 15,440 KB
最終ジャッジ日時 2023-09-22 01:34:39
合計ジャッジ時間 3,354 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
15,428 KB
testcase_01 AC 80 ms
15,440 KB
testcase_02 WA -
testcase_03 AC 83 ms
15,384 KB
testcase_04 AC 15 ms
7,824 KB
testcase_05 AC 15 ms
7,860 KB
testcase_06 AC 15 ms
7,948 KB
testcase_07 AC 15 ms
7,864 KB
testcase_08 WA -
testcase_09 AC 15 ms
7,808 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 15 ms
7,908 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 15 ms
7,948 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 15 ms
7,808 KB
testcase_22 WA -
testcase_23 AC 15 ms
7,856 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

T, A, B = map(int, input().split())

def solve(T, A, B):
    if abs(A) > T or abs(B) > T:
        return False
    U, S1, D = convert(A, T)
    R, S2, L = convert(B, T)
    if S1 == 1 and S2 == 1 and T == 1:
        return False
    UD = '^' * U + 'v' * D + ' ' * S1
    RL = ' ' * S2 + '>' * R + '<' * L
    return [ud + rl for ud, rl in zip(UD, RL)]
    

def convert(A, T):
    '''T 個の 1, 0, -1 の和として、Aをあらわす。
    できるだけ、0 が少なくなるようにする。
    a + b + c = T
    a     - c = A
    a, b, c は 0 以上 T 以下の整数 をみたす、a, b, c を求めればよい。
    c = a - A
    と書けるので、
    a + b + c = a + b + a - A = 2 * a + b - A = T
    2 * a + b = A + T
    b = A + T - 2 * a
    
    T >= a - A >= 0 -> a >= A
    
    '''
    a, b =  divmod(A + T, 2)
    c = a - A
    return   a, b, c

ans = solve(T, A, B)
if not ans:
    print('NO')
else:
    print('YES')
    for move in ans:
        print(move)
0