#include //#include using namespace std; // using namespace atcoder; // using mint = modint1000000007; // const int mod = 1000000007; // using mint = modint998244353; // const int mod = 998244353; // const int INF = 1e9; // const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i, l, r) for (int i = (l); i < (r); ++i) #define rrep(i, n) for (int i = (n)-1; i >= 0; --i) #define rrep2(i, l, r) for (int i = (r)-1; i >= (l); --i) #define all(x) (x).begin(), (x).end() #define allR(x) (x).rbegin(), (x).rend() #define P pair template inline bool chmax(A& a, const B& b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A& a, const B& b) { if (a > b) { a = b; return true; } return false; } #ifndef KWM_T_ALGORITHM_RUN_LENGTH_ENCODING_HPP #define KWM_T_ALGORITHM_RUN_LENGTH_ENCODING_HPP #include #include #include namespace kwm_t::algorithm { /** * @brief Run Length Encoding(連長圧縮) * * 任意の forward iterator に対して適用可能 * * 計算量: * O(N) * * 制約: * - 要素型に == が定義されていること * verified * https://atcoder.jp/contests/abc452/submissions/74695137 * https://atcoder.jp/contests/awc0051/submissions/75170743 */ template std::vector::value_type, int>> run_length_encoding(It first, It last) { using T = typename std::iterator_traits::value_type; std::vector> ret; if (first == last) return ret; It it = first; while (it != last) { It jt = it; int cnt = 0; while (jt != last && *jt == *it) { ++jt; ++cnt; } ret.emplace_back(*it, cnt); it = jt; } return ret; } // コンテナ版 template std::vector> run_length_encoding(const Container& c) { return run_length_encoding(c.begin(), c.end()); } } // namespace kwm_t::algorithm #endif // KWM_T_ALGORITHM_RUN_LENGTH_ENCODING_HPP int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; cin >> t; while (t--) { int n; cin >> n; vectorh(n); rep(i, n)cin >> h[i]; vectorv; rep(i, n - 1) { if (h[i] < h[i + 1])v.push_back(0); else v.push_back(1); } // 111000111000 auto l = kwm_t::algorithm::run_length_encoding(v); if (l.size() == 4 && l[0].first == 1)cout << "Yes" << endl; else cout << "No" << endl; } return 0; }