結果
| 問題 | 
                            No.2518 Adjacent Larger
                             | 
                    
| コンテスト | |
| ユーザー | 
                             emthrm
                         | 
                    
| 提出日時 | 2023-10-27 21:47:04 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,278 bytes | 
| コンパイル時間 | 2,853 ms | 
| コンパイル使用メモリ | 249,928 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-25 13:52:27 | 
| 合計ジャッジ時間 | 3,797 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 19 WA * 9 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr double EPS = 1e-8;
constexpr int MOD = 998244353;
// constexpr int MOD = 1000000007;
constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1};
constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1};
constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U>
inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U>
inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);
  }
} iosetup;
void solve() {
  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  if (ranges::count(a, 0) == 0 || ranges::count(a, 2) == 0) {
    cout << "No\n";
    return;
  }
  REP(i, n) {
    if (a[i] != 1 && a[i] == a[(i + 1) % n]) {
      cout << "No\n";
      return;
    }
    if (a[i] == 0 && a[(i + 2) % n] == 0 && a[(i + 1) % n] != 2) {
      cout << "No\n";
      return;
    }
    if (a[i] == 2 && a[(i + 2) % n] == 2 && a[(i + 1) % n] != 0) {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}
int main() {
  // const int n = 4;
  // vector<int> a(n);
  // iota(a.begin(), a.end(), 0);
  // set<vector<int>> st;
  // do {
  //   vector<int> b(n);
  //   REP(i, n) b[i] = (a[(i - 1 + n) % n] > a[i]) + (a[(i + 1) % n] > a[i]);
  //   st.emplace(b);
  // } while (ranges::next_permutation(a).found);
  // vector<int> c(n);
  // const auto f = [&](auto f, const int i, const bool has_0, const bool has_2) -> void {
  //   if (i == n) {
  //     if (has_0 && has_2 && (c.back() == 1 || c.front() != c.back())) {
  //       if (!st.contains(c)) {
  //         REP(i, n) cout << c[i] << " \n"[i + 1 == n];
  //         exit(0);
  //       }
  //     }
  //     return;
  //   }
  //   REP(x, 3) {
  //     c[i] = x;
  //     if (i == 0 || c[i] == 1 || c[i - 1] != c[i]) f(f, i + 1, has_0 || x == 0, has_2 || x == 2);
  //   }
  // };
  // f(f, 0, false, false);
  int t; cin >> t;
  while (t--) solve();
  return 0;
}
            
            
            
        
            
emthrm