Created
September 10, 2017 13:38
-
-
Save mi6112ogit/e57fcf9d68c75f757fd3841c7dd1b67a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
//#define int long long | |
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i) | |
#define rep(i, j) FOR(i, 0, j) | |
#define INF (1 << 30) | |
typedef unsigned long long ull; | |
typedef pair<int, int> P; | |
typedef pair<P, int> Pi; | |
const int MOD = 1e9 + 7; | |
const int dy[] = {0, 0, 1, -1}; | |
const int dx[] = {1, -1, 0, 0}; | |
template <class T> void chmin(T& a, const T& b) { a = min(a, b); } | |
template <class T> void chmax(T& a, const T& b) { a = max(a, b); } | |
int ball[10]; | |
bool dfs(int n, int b, int c) { | |
if(n == 10) return true; | |
if(b < ball[n]) return dfs(n + 1, b = ball[n], c); | |
if(c < ball[n]) return dfs(n + 1, b, c = ball[n]); | |
return false; | |
} | |
signed main() { | |
cin.tie(0); | |
ios::sync_with_stdio(false); | |
int n; | |
cin >> n; | |
rep(i, n) { | |
rep(i, 10) cin >> ball[i]; | |
dfs(0, 0, 0) ? cout << "YES" : cout << "NO"; | |
cout << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment