Go: package main

import "fmt"

func isOrdered(a []int) bool {
	if len(a) <= 1 {
		return true
	}
	for i := 0; i+1 < len(a); i++ {
		if a[i] > a[i+1] {
			return false
		}
	}
	return true
}

func main() {
	// ボールの数がせいぜい10個しかないので、全てのボールの落とし方を全探索することが可能
	// Bit全探索を行う。右から見てj番目のビットが立っているときには左側の筒、立っていない時は右側の筒にいれる物とする。
	// 全てのボールを落とし終わった後に、それぞれの筒で昇順に並んでいるか調べることにする。
	var t int
	fmt.Scan(&t)
	ans := make([]bool, t)
	for i := 0; i < t; i++ {
		balls := make([]int, 10)
		for i := range balls {
			fmt.Scan(&balls[i])
		}
		ans[i] = false
		for bits := 0; bits < (1 << uint(10)); bits++ {
			pipeB := make([]int, 0)
			pipeC := make([]int, 0)
			for j := 0; j < 10; j++ {
				if (bits & (1 << uint(j))) != 0 {
					pipeB = append(pipeB, balls[j])
				} else {
					pipeC = append(pipeC, balls[j])
				}
			}
			if isOrdered(pipeB) && isOrdered(pipeC) {
				// fmt.Printf("test case %d - OK pattern - pipeB %v, pipec %v\n", i, pipeB, pipeC)
				ans[i] = true
				break
			}
		}
	}
	for i := range ans {
		if ans[i] {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

C++: #include <iostream>
#include <string>
#include <vector>

std::string answer;
std::vector<int> input, left, right;

void dfs(int i, std::vector<int> L, std::vector<int> R){
	int temp, L_flag, R_flag;
	std::vector<int> Add_L, Add_R;

	if(answer.compare("YES")==0 || i>9) return;

	L_flag = R_flag = 0;
	if(L.size()>0){
		temp = L[0];
		for(unsigned int j=1; j<L.size(); j++){
			if(temp>L[j]){
				L_flag = 1;
				break;
			}
			temp = L[j];
		}
	}
	if(R.size()>0){
		temp = R[0];
		for(unsigned int j=1; j<R.size(); j++){
			if(temp>R[j]){
				R_flag = 1;
				break;
			}
			temp = R[j];
		}
	}

	if(L_flag>0 || R_flag>0) { return; }
	else if(L_flag==0 && R_flag==0 && i==9) { answer = "YES"; }
	
	Add_L = L;
	Add_L.insert(Add_L.end(), input[i]);
	Add_R = R;
	Add_R.insert(Add_R.end(), input[i]);

	dfs(i+1, Add_L, R);
	dfs(i+1, L, Add_R);
}

int main(void){
	int n, number;
	std::cin >> n;

	for(int i=0;i<n;i++){
		input.clear();
		left.clear();
		right.clear();
		
		for(int j=0;j<10;j++){
			std::cin >> number;
			input.insert(input.end(), number);
		}
		answer = "CHECK";
		dfs(0, left, right);
		if(answer.compare("CHECK")==0) answer="NO";
		std::cout << answer << std::endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
	int n,ball,tp[2],con;
	
	cin >> n;
	
	for(; n > 0; n--){
		
		tp[0] = tp[1] = 0;
		
		for(int i = 0; i < 10; i++){
			cin >> ball;
			
			if(tp[0] > tp[1]){
				con = 0;
			}else{
				con = 1;
			}
			
			if(ball > tp[con]){
				tp[con] = ball;
			}else if(ball > tp[!con]){
				tp[!con] = ball;
			}else{
				cout << "NO" << endl;
				break;
			}
			
			if(i == 9){
				cout << "YES" << endl;
			}
		}
	}
	
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int nums[10];
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		int a;
		for(int j = 0; j < 10; j++){
			cin >> a;
			nums[j] = a;
		}
		int l = 0, r = 0;
		for(int i = 0; i < 10; i++){
			int minimum = min(l, r);
			int maximum = max(l, r);
			if(nums[i] < minimum){
				cout << "NO" << endl;
				break;
			}
			if(nums[i] > maximum){
				if(l > r){
					l = nums[i];
				} else {
					r = nums[i];
				}
			} else {
				if(nums[i] > l){
					l = nums[i];
				}else if(nums[i] > r){
					r = nums[i];
				}
			}
			if(i == 9)
				cout << "YES" << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
 
int main()
{	
	int n;
	cin>>n;
	while(n--){
		int a[10];
		for(int i=0;i<10;i++){
			cin>>a[i];
		}
		bool rt1=true,rt2=true;
		for(int i=0;i<8;i=i+2){
			if(a[i]>a[i+2]) rt1=false;		
		}
		
		for(int i=1;i<8;i=i+2){
			if(a[i]>a[i+2]) rt2=false;		
		}
		if(rt1==true && rt2==true) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
int ball[10];
int left = 0,right = 0;
bool dfs(int de,int left, int right){//??????????????§???????????????
	if(de == 9)return true;
	if(left < ball[de]){
		left = ball[de];
		return dfs(de + 1);
	}
	if(right < ball[de]){
		right = ball[de];
		return dfs(de + 1);
	}
	return false;
}

int main(){
	int n;
	std::cin >> n;
	while(n--){
		for(int i = 0; i < 10; ++i){
			std::cin >> ball[i];
		}
		left = 0, right = 0;
		if(dfs(0,0,0))std::cout << "YES" << std::endl;
		else std::cout << "NO" << std::endl;
	}
}

C++: #include <iostream>
#include <string>
using namespace std;

int main()
{
    int n ;
	int ball[11] , b[11] , c[11];
	cin >> n ;
	for(int j=0 ; j<n ; j++){
		int flag=0, cntb=1 , cntc=1;
		for(int i=1 ; i<=10 ;i++){
			cin >> ball[i] ;
		}

		b[0]=0;
		c[0]=0;

		for(int i=1 ; i<=10 ; i++){
			if(b[cntb-1] < ball[i]){
				b[cntb]=ball[i];
				cntb++;
			}else if(c[cntc-1] < ball[i]){
				c[cntc]=ball[i];
				cntc++;
			}else{
				flag++;
				break;
			}
		}
		if(flag==0){
			cout <<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}

	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
int a[13],b[13],c[13],flag;
void dfs(int step,int bn,int cn)
{
    if(step==10){
        flag=1;
        return ;
    }
    if(flag) return ;
    if(a[step]>b[bn]){
    	b[bn]=a[step];
    	dfs(step+1,bn+1,cn);
	}
    if(a[step]>c[cn]){
    	c[cn]=a[step];
    	dfs(step+1,bn,cn+1);
	}
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--){
        flag=0;
        for(int i=0;i<10;i++)
            scanf("%d",&a[i]);
        dfs(0,0,0);
        if(flag) printf("YES\n");
        else printf("NO\n");
    }
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std;
const int N = 20 + 5;

int T;

int main()
{
    scanf("%d", &T);
    while(T--)
    {
        int left = 0, right = 0, flag = 0;
        for(int i = 0; i < 10; i++)
        {
            int tmp;
            scanf("%d", &tmp);
            if(tmp > left) left =tmp;
            else if(tmp > right) right = tmp;
            else flag = 1;
        }
        if(flag)
            printf("NO\n");
        else
            printf("YES\n");
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

void solve()
{
    int arr[10];
    for (int i = 0; i < 10; ++i)
        cin >> arr[i];
    bool f = false;
    for (int bit = 0; bit < (1 << 10); ++bit)
    {
        bool judge = true;
        vector<int> v1, v2;
        for (int i = 0; i < 10; ++i)
        {
            if (bit >> i & 1)
                v1.push_back(arr[i]);
            else
                v2.push_back(arr[i]);
        }

        int n = v1.size();
        int m = v2.size();
        for (int i = 0; i < n - 1; ++i)
        {
            if (v1[i] < v1[i + 1])
                continue;
            else
                judge = false;
        }

        for (int i = 0; i < m - 1; ++i)
        {
            if (v2[i] < v2[i + 1])
                continue;
            else
                judge = false;
        }

        if (judge)
        {
            f = judge;
            break;
        }
    }
    if (f)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(3);

    int n;
    cin >> n;
    while (n--)
    {
        solve();
    }
    return 0;
}