結果

問題 No.966 引き算をして門松列(その1)
ユーザー Konton7Konton7
提出日時 2020-01-13 21:19:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,620 bytes
コンパイル時間 138 ms
コンパイル使用メモリ 10,736 KB
実行使用メモリ 8,400 KB
最終ジャッジ日時 2023-08-24 14:07:59
合計ジャッジ時間 986 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,728 KB
testcase_01 AC 16 ms
7,940 KB
testcase_02 AC 16 ms
7,908 KB
testcase_03 AC 15 ms
7,772 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 86 ms
8,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def makekado(x, y, z):
    ans = 0
    maxxyz = max(x, y, z)
    minxyz = min(x, y, z)
    if x > z:
        x, z = z, x
    
    if x == y and y == z:
        if x >= 3:
            ans = 3
        else:
            ans = -1
    elif x == z:
        if maxxyz == y:
            if x == 1:
                ans = -1
            else:
                ans = 1
            
        if minxyz == y:
            if y == 1:
                if x == 2:
                    ans = -1
                else:
                    ans = 1
            else:
                if y == x - 1:
                    ans = 2
                else:
                    ans = 1
    
    
    else:
        if maxxyz == y:
            if y > z:
                ans = 0
            else:
                if y < 3:
                    ans = -1
                else:
                    if y - x == 1:
                        ans = 2
                    else:
                        ans = -1
        
        elif minxyz == y:
            if y < x:
                ans = 0
            else:
                if x == 1:
                    ans = -1
                else:
                    ans = 1
                    
        else:
            if x == 1:
                if y == 2:
                    ans = -1
                else:
                    ans = z - y + 1
            else:
                if y == x + 1:
                    ans = 2
                else:
                    ans = min(y - x, z - y) + 1
    print(ans)
    return


n = int(input())
for i in range(n):
    a, b, c = [ int(v) for v in input().split() ]
    makekado(a, b, c)
0