結果

問題 No.3286 Make a Happy Connection
ユーザー もろこし
提出日時 2025-10-03 22:01:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 600 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 82,588 KB
実行使用メモリ 54,548 KB
最終ジャッジ日時 2025-10-03 22:01:23
合計ジャッジ時間 2,419 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10**7)
def ii(): return int(input())
def mi(d=0): return map(lambda x:int(x)-d,input().split())
INF = float("inf")
MOD = 998244353
def answer(s):
  print(s)
  exit()
def cross(xy):
  x,y = xy
  return (x+1,y),(x-1,y),(x,y+1),(x,y-1)
################################################
n = ii()
a = list(mi())
if n == 2:
  ans = "Yes" if a[0] == a[1] else "No"
  print(ans)
else:
  l,r = -1,-1
  for i in range(n-1):
    if i+2 < n:
      r = a[i+2]
    else:
      r = -1
    if l == a[i+1] or r == a[i] or a[i] == a[i+1]:
      answer("Yes")
    l = a[i]
  print("No")
0