結果
問題 | No.1369 交換門松列・竹 |
ユーザー | GER_chen |
提出日時 | 2021-01-29 22:44:01 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,578 bytes |
コンパイル時間 | 660 ms |
コンパイル使用メモリ | 81,980 KB |
実行使用メモリ | 267,096 KB |
最終ジャッジ日時 | 2024-06-27 09:07:07 |
合計ジャッジ時間 | 5,360 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
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 | -- | - |
ソースコード
#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 flag = 0 for i in range(min(3, n-b0)): if not flag: 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 flag = 1 break if ct == 2: b0, b1 = B b = 1 for i in range(min(3, n-b0)): 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], B)