結果

問題 No.3286 Make a Happy Connection
ユーザー a01sa01to
提出日時 2025-10-04 00:39:07
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 2,987 ms
コンパイル使用メモリ 278,696 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-04 00:39:11
合計ジャッジ時間 3,719 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  bool ans = false;
  rep(i, n - 1) ans |= a[i] == a[i + 1];
  rep(i, n - 1) {
    swap(a[i], a[i + 1]);
    if (i > 0) ans |= a[i - 1] == a[i];
    if (i + 2 < n) ans |= a[i + 1] == a[i + 2];
    swap(a[i], a[i + 1]);
  }
  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}
0