結果

問題 No.1369 交換門松列・竹
ユーザー GER_chenGER_chen
提出日時 2021-01-29 22:37:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,429 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 87,152 KB
実行使用メモリ 264,472 KB
最終ジャッジ日時 2023-09-09 16:10:30
合計ジャッジ時間 6,543 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
82,388 KB
testcase_01 WA -
testcase_02 AC 78 ms
75,580 KB
testcase_03 AC 78 ms
75,504 KB
testcase_04 AC 79 ms
75,584 KB
testcase_05 AC 80 ms
75,324 KB
testcase_06 AC 80 ms
75,672 KB
testcase_07 AC 72 ms
71,228 KB
testcase_08 AC 70 ms
71,276 KB
testcase_09 AC 69 ms
70,980 KB
testcase_10 AC 70 ms
71,136 KB
testcase_11 AC 70 ms
71,448 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#1369
#import sys;input = lambda: sys.stdin.readline().rstrip()
#import heapq
#from collections import deque
#import numpy as np
#from collections import Counter as cnt
#from collections import defaultdict as ddc
#from math import factorial as fct
#from math import gcd
#from bisect import bisect_left as bsl
#from bisect import bisect_right as bsr
#from itertools import accumulate as acc
#from itertools import combinations as cmb
#from itertools import permutations as pmt
#from itertools import product as prd
#from functools import reduce as red
#import sys
#sys.setrecursionlimit(10**9)  #再帰を多く使う(デフォルトは1000)
def kadomatsu(L):
    """kadomatsuならTrueを返す"""
    if len(set(L)) == 3 and L[1] in {min(L), max(L)}:
        return True
    return False
    
for _ in range(int(input())):
    n = int(input())
    A = list(map(int,input().split()))
    Sub = [A[i:i+3] for i in range(n-2)]
    Nk, ct, bct, B, b = [], 0, 0, [], 0  #bが0ならイエス、1ならノー
    for i, S in enumerate(Sub):
        if not kadomatsu(S):
            if Nk == []:
                ct += 1
                bct = i
                B.append(i)
            else:
                if bct+2 < i:
                    ct += 1
                    bct = i
                    B.append(i)
            if ct > 2:
                b = 1
                break
            Nk.append(i)
    if ct == 1:
        b0 = B[0]
        b = 1
        for i in range(min(3, n-b0)):
            for j in range(n):
                if A[b0+i] != A[j]:
                    X = [a for a in A]
                    X[b0+i], X[j] = X[j], X[b0+i]
                    if all([kadomatsu(X[b0+i+k:b0+i+k+3]) for k in range(max(-2, -b0-i), min(3, n-3-b0-i))]):
                        if all([kadomatsu(X[j+k:j+k+3]) for k in range(max(-2, -j), min(3, n-3-j))]):
                            b = 0
        pass
    if ct == 2:
        b0, b1 = B
        b = 1
        for i in range(3):
            for j in range(min(3, n-b1)):
                if A[b0+i] != A[b1+j]:
                    X = [a for a in A]
                    X[b0+i], X[b1+j] = X[b1+j], X[b0+i]
                    if all([kadomatsu(X[b0+i+k:b0+i+k+3]) for k in range(max(-2, -b0-i), min(3, n-3-b0-i))]):
                        if all([kadomatsu(X[b1+j+k:b1+j+k+3]) for k in range(max(-2, -b1-j), min(3, n-3-b1-j))]):
                            b = 0
    print('YNeos'[b::2])
0