結果
| 問題 |
No.966 引き算をして門松列(その1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-29 22:08:10 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,452 bytes |
| コンパイル時間 | 299 ms |
| コンパイル使用メモリ | 12,416 KB |
| 実行使用メモリ | 12,544 KB |
| 最終ジャッジ日時 | 2025-01-02 15:51:19 |
| 合計ジャッジ時間 | 1,820 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 2 |
| other | RE * 5 |
ソースコード
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul, add
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
T = INT()
for _ in range(T):
A, B, C = MAP()
if A == B == C and A != 2 and A != 1:
print(3)
continue
elif A == B == C:
print(-1)
continue
if A >= B >= C:
if B-1 != C: # AをB-1に
tmp = A-(B-1)
elif B-1 == C and B-2 != 0: # AをB-2に
tmp = A-(B-2)
else: # B-2が0
tmp = INF
if C-1 != 0:
tmp2 = B-(C-1)
else:
tmp2 = INF
ans = min(tmp, tmp2)
print(ans if ans != INF else -1)
elif A <= B <= C:
C, A = A, C
if B-1 != C:
tmp = A-(B-1)
elif B-1 == C and B-2 != 0:
tmp = A-(B-2)
else: # B-2が0
tmp = INF
if C-1 != 0:
tmp2 = B-(C-1)
else:
tmp2 = INF
ans = min(tmp, tmp2)
print(ans if ans != INF else -1)
else:
print(0)