結果

問題 No.1369 交換門松列・竹
ユーザー titiatitia
提出日時 2021-01-29 22:16:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,063 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 18,616 KB
最終ジャッジ日時 2023-09-09 15:44:15
合計ジャッジ時間 18,282 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,856 KB
testcase_01 AC 18 ms
8,320 KB
testcase_02 AC 16 ms
8,260 KB
testcase_03 AC 16 ms
8,224 KB
testcase_04 AC 16 ms
8,328 KB
testcase_05 AC 16 ms
8,176 KB
testcase_06 AC 16 ms
8,156 KB
testcase_07 AC 17 ms
8,304 KB
testcase_08 AC 16 ms
8,188 KB
testcase_09 AC 17 ms
8,336 KB
testcase_10 AC 17 ms
8,172 KB
testcase_11 AC 15 ms
8,164 KB
testcase_12 AC 16 ms
8,192 KB
testcase_13 AC 140 ms
8,188 KB
testcase_14 WA -
testcase_15 AC 308 ms
14,048 KB
testcase_16 AC 390 ms
13,880 KB
testcase_17 AC 425 ms
14,052 KB
testcase_18 AC 393 ms
13,952 KB
testcase_19 AC 275 ms
14,144 KB
testcase_20 AC 1,769 ms
14,156 KB
testcase_21 AC 264 ms
14,132 KB
testcase_22 AC 1,518 ms
14,008 KB
testcase_23 AC 352 ms
14,100 KB
testcase_24 TLE -
testcase_25 AC 1,550 ms
8,292 KB
testcase_26 AC 1,315 ms
8,388 KB
testcase_27 AC 1,305 ms
8,288 KB
testcase_28 AC 1,609 ms
8,996 KB
testcase_29 TLE -
testcase_30 AC 68 ms
18,468 KB
testcase_31 AC 68 ms
18,616 KB
testcase_32 AC 60 ms
8,228 KB
testcase_33 AC 366 ms
8,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def kado(x,y,z):
    if x==z:
        return 0
    
    if y<x and y<z:
        return 1
    if y>x and y>z:
        return 1
    return 0
        
T=int(input())
for tests in range(T):
    N=int(input())
    A=list(map(int,input().split()))

    NO=[]
    for i in range(1,N-1):
        if kado(A[i-1],A[i],A[i+1])==0:
            NO.extend([i-1,i,i+1])

    NO=sorted(set(NO))

    flag=0

    if len(NO)<=50:
        for x in NO:
            if flag==1:
                break
            for i in range(N):
                if flag==1:
                    break
                if x==i:
                    continue

                A[x],A[i]=A[i],A[x]

                for a in NO+list(range(i-2,i+3)):
                    if a<=0 or a>=N-1:
                        continue
                    if kado(A[a-1],A[a],A[a+1])==0:
                        break
                else:
                    print("Yes")
                    flag=1
                    break

                A[x],A[i]=A[i],A[x]

    if flag==0:
        print("No")
                    
0