結果
問題 | No.1369 交換門松列・竹 |
ユーザー | Kude |
提出日時 | 2021-01-29 23:19:52 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,646 bytes |
コンパイル時間 | 143 ms |
コンパイル使用メモリ | 81,996 KB |
実行使用メモリ | 85,888 KB |
最終ジャッジ日時 | 2024-06-27 09:48:01 |
合計ジャッジ時間 | 4,578 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
52,224 KB |
testcase_01 | AC | 40 ms
52,480 KB |
testcase_02 | AC | 39 ms
52,096 KB |
testcase_03 | AC | 39 ms
52,608 KB |
testcase_04 | AC | 39 ms
51,968 KB |
testcase_05 | AC | 39 ms
52,736 KB |
testcase_06 | AC | 38 ms
52,352 KB |
testcase_07 | AC | 39 ms
52,224 KB |
testcase_08 | AC | 39 ms
52,096 KB |
testcase_09 | AC | 38 ms
52,224 KB |
testcase_10 | AC | 40 ms
52,352 KB |
testcase_11 | AC | 38 ms
52,224 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 285 ms
78,492 KB |
testcase_15 | AC | 103 ms
84,520 KB |
testcase_16 | AC | 113 ms
84,864 KB |
testcase_17 | AC | 113 ms
84,608 KB |
testcase_18 | AC | 113 ms
84,608 KB |
testcase_19 | AC | 106 ms
84,992 KB |
testcase_20 | AC | 117 ms
84,864 KB |
testcase_21 | AC | 102 ms
84,784 KB |
testcase_22 | AC | 115 ms
84,528 KB |
testcase_23 | AC | 110 ms
84,676 KB |
testcase_24 | AC | 114 ms
85,120 KB |
testcase_25 | AC | 163 ms
77,412 KB |
testcase_26 | AC | 170 ms
77,232 KB |
testcase_27 | AC | 166 ms
77,192 KB |
testcase_28 | AC | 113 ms
83,888 KB |
testcase_29 | AC | 123 ms
84,024 KB |
testcase_30 | AC | 65 ms
85,888 KB |
testcase_31 | AC | 66 ms
84,480 KB |
testcase_32 | AC | 158 ms
77,180 KB |
testcase_33 | AC | 113 ms
84,352 KB |
ソースコード
def solve(): n = int(input()) a = list(map(int, input().split())) for z in range(2): n = len(a) broken_adj = [] broken_even = [] broken_odd = [] for i in range(n - 1): d = a[i+1] - a[i] if i & 1 == 0 and d <= 0 or i & 1 == 1 and d >= 0: broken_adj.append(i) for i in range(n - 2): if a[i] == a[i+2]: if i & 1 == 0: broken_even.append(i) else: broken_odd.append(i) if max(map(len, [broken_adj, broken_even, broken_odd])) <= 8: if broken_adj: s = broken_adj[0] t = s + 1 elif broken_even: s = broken_even[0] t = s + 2 else: s = broken_odd[0] t = s + 2 for i in (s, t): for j in range(n): if i == j: continue a[i], a[j] = a[j], a[i] for k in (i, j): if (0 <= k - 2 and a[k-2] == a[k] or k + 2 < n and a[k] == a[k+2] or k & 1 == 0 and ( 0 <= k - 1 and a[k-1] <= a[k] or k + 1 < n and a[k] >= a[k+1]) or k & 1 == 1 and ( 0 <= k - 1 and a[k-1] >= a[k] or k + 1 < n and a[k] <= a[k+1] )): break else: ba = set(broken_adj) be = set(broken_even) bo = set(broken_odd) for k in (i, j): if k - 2 in bo: bo.remove(k - 2) if k - 2 in be: be.remove(k - 2) if k - 1 in ba: ba.remove(k - 1) if k in bo: bo.remove(k) if k in be: be.remove(k) if k in ba: ba.remove(k) if max(map(len, [ba, be, bo])) == 0: print('Yes') return a[i], a[j] = a[j], a[i] if z == 0: a = [0] + a print('No') return for _ in range(int(input())): solve()