結果
問題 | No.2518 Adjacent Larger |
ユーザー | MasKoaTS |
提出日時 | 2023-10-27 12:36:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 202 ms / 2,000 ms |
コード長 | 1,556 bytes |
コンパイル時間 | 394 ms |
コンパイル使用メモリ | 82,428 KB |
実行使用メモリ | 117,716 KB |
最終ジャッジ日時 | 2024-09-25 12:59:39 |
合計ジャッジ時間 | 6,964 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 128 ms
86,016 KB |
testcase_01 | AC | 202 ms
90,188 KB |
testcase_02 | AC | 196 ms
90,008 KB |
testcase_03 | AC | 191 ms
90,072 KB |
testcase_04 | AC | 195 ms
90,056 KB |
testcase_05 | AC | 190 ms
89,848 KB |
testcase_06 | AC | 159 ms
89,344 KB |
testcase_07 | AC | 162 ms
89,832 KB |
testcase_08 | AC | 170 ms
89,284 KB |
testcase_09 | AC | 162 ms
89,648 KB |
testcase_10 | AC | 162 ms
89,644 KB |
testcase_11 | AC | 158 ms
89,104 KB |
testcase_12 | AC | 150 ms
89,364 KB |
testcase_13 | AC | 151 ms
89,224 KB |
testcase_14 | AC | 152 ms
89,288 KB |
testcase_15 | AC | 149 ms
89,216 KB |
testcase_16 | AC | 186 ms
117,628 KB |
testcase_17 | AC | 164 ms
103,968 KB |
testcase_18 | AC | 163 ms
103,488 KB |
testcase_19 | AC | 163 ms
101,964 KB |
testcase_20 | AC | 171 ms
108,532 KB |
testcase_21 | AC | 174 ms
117,588 KB |
testcase_22 | AC | 174 ms
117,488 KB |
testcase_23 | AC | 183 ms
117,716 KB |
testcase_24 | AC | 175 ms
117,536 KB |
testcase_25 | AC | 181 ms
117,436 KB |
testcase_26 | AC | 179 ms
117,428 KB |
testcase_27 | AC | 172 ms
117,460 KB |
testcase_28 | AC | 184 ms
117,568 KB |
ソースコード
import itertools as iter import collections as coll import heapq as hq import bisect as bis from decimal import Decimal as dec from functools import cmp_to_key import math import sys #import pypyjit #pypyjit.set_param('max_unroll_recursion=-1') sys.setrecursionlimit(10 ** 6) inp = sys.stdin.readline input = lambda : inp()[:-1] getN = lambda : int(inp()) getNs = lambda : map(int, inp().split()) getList = lambda :list(map(int, inp().split())) getStrs = lambda n : [input() for _ in [0] * n] getEdges = lambda n : [[x - 1 for x in getNs()] for _ in [0] * n] def yexit(): print("Yes"); exit(0) def nexit(): print("No"); exit(0) pi = 3.141592653589793 mod = 1000000007 MOD = 998244353 INF = 4611686018427387903 dx = [1, 0, -1, 0]; dy = [0, 1, 0, -1] #di = coll.defaultdict(int) """ Main Code """ def solve(n, a): if(2 not in a): return "No" id_start = a.index(2) dirs = [0] * n for i in range(n): j = (id_start + i) % n k = (j - 1) % n if(a[j] == 2): dirs[j], dirs[k] = 1, 0 elif(a[j] == 1): dirs[j] = dirs[k] else: dirs[j], dirs[k] = 0, 1 for i in range(n): j = (id_start + i) % n k = (j - 1) % n if(a[j] == 2 and (dirs[j], dirs[k]) != (1, 0)): return "No" if(a[j] == 1 and dirs[j] != dirs[k]): return "No" if(a[j] == 0 and (dirs[j], dirs[k]) != (0, 1)): return "No" return "Yes" t = getN() for _ in [0] * t: n = getN() a = getList() print(solve(n, a))