結果

問題 No.2343 (l+r)/2
ユーザー risujirohrisujiroh
提出日時 2023-06-09 21:49:44
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,886 bytes
コンパイル時間 3,440 ms
コンパイル使用メモリ 248,612 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-30 13:09:48
合計ジャッジ時間 4,283 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 33 ms
4,504 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 8 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 9 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

namespace std {

template <class T1, class T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
  return is >> p.first >> p.second;
}

template <class... Ts>
istream& operator>>(istream& is, tuple<Ts...>& t) {
  return apply([&is](auto&... xs) -> istream& { return (is >> ... >> xs); }, t);
}

template <class... Ts>
istream& operator>>(istream& is, tuple<Ts&...>&& t) {
  return is >> t;
}

template <class R, enable_if_t<!is_convertible_v<R, string>>* = nullptr>
auto operator>>(istream& is, R&& r) -> decltype(is >> *begin(r)) {
  for (auto&& e : r) {
    is >> e;
  }
  return is;
}

template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << p.first << ' ' << p.second;
}

template <class... Ts>
ostream& operator<<(ostream& os, const tuple<Ts...>& t) {
  auto f = [&os](const auto&... xs) -> ostream& {
    [[maybe_unused]] auto sep = "";
    ((os << exchange(sep, " ") << xs), ...);
    return os;
  };
  return apply(f, t);
}

template <class R, enable_if_t<!is_convertible_v<R, string_view>>* = nullptr>
auto operator<<(ostream& os, R&& r) -> decltype(os << *begin(r)) {
  auto sep = "";
  for (auto&& e : r) {
    os << exchange(sep, " ") << e;
  }
  return os;
}

}  // namespace std

// end library

namespace std::ranges::views {

namespace {

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  bool ans = [&] {
    if (a[0] != a.back()) {
      return true;
    }
    if (adjacent_find(a, [&](int x, int y) {
          return x != a[0] && y != a[0];
        }) == a.end()) {
      return false;
    }
    return true;
  }();
  cout << (ans ? "Yes\n" : "No\n");
}

}  // namespace

}  // namespace std::ranges::views

using views::solve;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
0