結果
問題 | No.1369 交換門松列・竹 |
ユーザー | mkawa2 |
提出日時 | 2021-11-12 03:05:46 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 2,467 bytes |
コンパイル時間 | 166 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 82,176 KB |
最終ジャッジ日時 | 2024-05-03 06:54:21 |
合計ジャッジ時間 | 4,150 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
52,480 KB |
testcase_01 | RE | - |
testcase_02 | AC | 44 ms
52,992 KB |
testcase_03 | AC | 46 ms
52,608 KB |
testcase_04 | AC | 43 ms
52,480 KB |
testcase_05 | AC | 43 ms
52,864 KB |
testcase_06 | AC | 42 ms
52,224 KB |
testcase_07 | AC | 43 ms
52,992 KB |
testcase_08 | AC | 43 ms
52,864 KB |
testcase_09 | AC | 42 ms
52,864 KB |
testcase_10 | AC | 42 ms
52,608 KB |
testcase_11 | AC | 42 ms
52,096 KB |
testcase_12 | AC | 42 ms
52,608 KB |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | AC | 117 ms
81,152 KB |
testcase_16 | AC | 64 ms
72,448 KB |
testcase_17 | AC | 64 ms
72,448 KB |
testcase_18 | AC | 64 ms
72,704 KB |
testcase_19 | AC | 119 ms
81,536 KB |
testcase_20 | AC | 64 ms
72,576 KB |
testcase_21 | AC | 116 ms
82,176 KB |
testcase_22 | AC | 64 ms
72,320 KB |
testcase_23 | AC | 64 ms
72,704 KB |
testcase_24 | AC | 65 ms
72,704 KB |
testcase_25 | AC | 93 ms
75,904 KB |
testcase_26 | AC | 88 ms
75,776 KB |
testcase_27 | AC | 101 ms
76,288 KB |
testcase_28 | AC | 62 ms
71,808 KB |
testcase_29 | AC | 63 ms
71,296 KB |
testcase_30 | AC | 56 ms
68,480 KB |
testcase_31 | AC | 58 ms
67,968 KB |
testcase_32 | RE | - |
testcase_33 | AC | 63 ms
71,936 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = 18446744073709551615 inf = 4294967295 md = 10**9+7 # md = 998244353 def iskado(abc): a, b, c = abc if a == b or b == c or c == a: return False if a < b < c or a > b > c: return False return True def solve(): def ok(i, j, lr0): res = True aa[i], aa[j] = aa[j], aa[i] s = max(0, min(i-2, lr0[0])) t = min(n, max(i, lr0[1]-2)) for k in range(s, t): if not iskado(aa[k:k+3]): res = False break aa[i], aa[j] = aa[j], aa[i] return res n = II() aa = LI() lr = [] l = r = -1 for i in range(n-2): if iskado(aa[i:i+3]): if l != -1 and i >= r: lr.append((l, r)) l = r = -1 else: if l == -1: l, r = i, i+3 else: r = i+3 if r-l == 10: return False if l != -1: lr.append((l, r)) if len(lr) > 2: return False if len(lr) == 2: for l, r in lr: if r-l > 5: return False for i in range(lr[0][0], lr[0][1]): for j in range(lr[1][0], lr[1][1]): if not ok(i, j, lr[0]): continue if not ok(j, i, lr[1]): continue return True if len(lr) == 1: l, r = lr[0] if r-l > 5: for i in range(lr[0][0], lr[0][1]): for j in range(lr[0][0], i): if not ok(i, j, lr[0]): continue if not ok(j, i, lr[0]): continue return True else: for i in range(lr[0][0], lr[0][1]): for j in range(n): if i == j: continue if not ok(i, j, lr[0]): continue if not ok(j, i, lr[0]): continue return True return False for _ in range(II()): print("Yes" if solve() else "No")