提出 #67333862


ソースコード 拡げる

import sys
import os
from math import ceil, floor, sqrt, pi, factorial, gcd,lcm,sin,cos,tan,asin,acos,atan2,exp,log,log10, isqrt, comb
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import cmp_to_key, lru_cache, reduce, cache
from operator import add, iand, ior, itemgetter, mul, xor
from string import ascii_lowercase, ascii_uppercase, ascii_letters
from typing import *
from bisect import bisect, bisect_left, bisect_right
from heapq import heapify, heappop, heappush, heappushpop, nlargest, nsmallest
from sortedcontainers import SortedSet, SortedList, SortedDict
from itertools import product, accumulate,permutations,combinations, count, groupby
input = lambda: sys.stdin.readline().rstrip("\r\n")
I = input
II = lambda: int(I())
LI = lambda: list(input().split())
LII = lambda: list(map(int, input().split()))
sys.setrecursionlimit(10000000)
inf = float('inf')

T = II()
for _ in range(T):
    N = II()
    A = LII()
    if N == 2:
        print("Yes")
        continue
    cnt = Counter(A)
    if len(cnt) == 1:
        print("Yes")
        continue
    if len(cnt) == 2:
        k_list = list(cnt.keys())
        if k_list[0] == k_list[1]*-1 and abs(cnt[k_list[0]]-cnt[k_list[1]])<2:
            print("Yes")
            continue
    A.sort(key=lambda a: abs(a))
    ans = True
    for i in range(1,N-1):
        if A[i-1]*A[i+1] != A[i]*A[i]:
            ans = False
    print("Yes" if ans else "No")

提出情報

提出日時
問題 D - Make Geometric Sequence
ユーザ GeekMasahiro
言語 Python (PyPy 3.10-v7.3.12)
得点 425
コード長 1457 Byte
結果 AC
実行時間 382 ms
メモリ 148480 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 425 / 425
結果
AC × 1
AC × 32
セット名 テストケース
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 02_handmade_31.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 152 ms 86300 KiB
01_random_01.txt AC 237 ms 90768 KiB
01_random_02.txt AC 323 ms 112576 KiB
01_random_03.txt AC 382 ms 148480 KiB
01_random_04.txt AC 298 ms 93136 KiB
01_random_05.txt AC 287 ms 105640 KiB
01_random_06.txt AC 231 ms 89848 KiB
01_random_07.txt AC 181 ms 114344 KiB
01_random_08.txt AC 253 ms 89292 KiB
01_random_09.txt AC 284 ms 91084 KiB
01_random_10.txt AC 246 ms 89956 KiB
01_random_11.txt AC 342 ms 119132 KiB
01_random_12.txt AC 247 ms 89492 KiB
01_random_13.txt AC 261 ms 89288 KiB
01_random_14.txt AC 266 ms 89340 KiB
01_random_15.txt AC 255 ms 94184 KiB
01_random_16.txt AC 262 ms 90012 KiB
01_random_17.txt AC 272 ms 90792 KiB
01_random_18.txt AC 254 ms 89276 KiB
01_random_19.txt AC 197 ms 117660 KiB
01_random_20.txt AC 244 ms 91308 KiB
01_random_21.txt AC 337 ms 113804 KiB
01_random_22.txt AC 286 ms 91716 KiB
01_random_23.txt AC 255 ms 89912 KiB
01_random_24.txt AC 355 ms 141972 KiB
01_random_25.txt AC 255 ms 89052 KiB
01_random_26.txt AC 302 ms 91412 KiB
01_random_27.txt AC 275 ms 97584 KiB
01_random_28.txt AC 324 ms 113244 KiB
01_random_29.txt AC 255 ms 90148 KiB
01_random_30.txt AC 244 ms 94140 KiB
02_handmade_31.txt AC 152 ms 86268 KiB