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 <stdio.h>

int main(void)
{
	int tubeM[10];
	int tube1[10], tube2[10];
	int i, j, k;
	int n;
	int ans;
	
	scanf("%d", &n);
	
	while(n){
		for (i = 0; i < 10; i++){
			tube2[i] = 0;
		}
		
		for (i = 0; i < 10; i++){
			scanf("%d", &tubeM[i]);
		}
		
		tube1[0] = tubeM[0];
		for (i = 1, j = 0, k = 0; i < 10; i++){
			if (tubeM[i] > tube1[j]){
				j++;
			}
			else {
				tube2[k] = tubeM[i];
				k++;
			}
		}
		
		ans = 0;
		for (i = 1; tube2[i] != 0; i++){
			if (tube2[i - 1] > tube2[i]){
				ans = 1;
				break;
			}
		}
		
		if (ans == 0){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
		
		n--;
	}
	
	return (0);
}

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

using namespace std;

int a[10];

int main()
{
    int t;
    cin >> t;

    while(t--)
    {
        for(int i = 0; i < 10; ++i)
        {
            cin>>a[i];
        }

        vector<int> x[2];
        auto lar = &x[0];
        auto sma = &x[1];

        bool ans = true;

        for(int i = 0; i < 10; ++i)
        {
            int c = a[i];

            if(i == 0){
                lar->push_back(c);
            }
            else if(c >= lar->back())
            {
                lar->push_back(c);
            }
            else if(sma->empty())
            {
                sma->push_back(c);
                
            }
            else if(c >= sma->back())
            {
                sma->push_back(c);
                
            }
            else
            {
                ans = false;
                break;
            }
            
        }
        if(ans)
            cout<<"YES" <<endl;
        else
            cout<<"NO" <<endl;

    }
}

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

using namespace std;

int n;
vector<int> vec;
int lcount, rcount, l, r;

bool dfs(int i)
{
	if(i == 10) return true;
	if(lcount < 10 && l < vec[i]){ l = vec[i]; if(dfs(i + 1)) return true; }
	if(rcount < 10 && r < vec[i]){ r= vec[i]; if(dfs(i + 1)) return true; }
	return false;
}

int main()
{
	cin >> n;
	for (int j = 0; j < n; j++)
	{
		lcount = 0; rcount = 0; l = 0; r = 0;
		vec.resize(10);

		for (int i = 0; i < 10; i++)
		{
			cin >> vec[i];
		}	
		cout << (dfs(0) ? "YES" : "NO") << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n,ball,a=0,b=0;
  cin >> n;
  for(int i=0;i<n;i++){
    int flg = 0;
    for(int i=0;i<10;i++){
      cin >> ball;
      if(a < ball){
	a = ball;
      } else if(b < ball){
	b = ball;
      } else{
	flg = 1;
      }
    }
    if(flg == 0){
      cout <<"YES" << endl;
    } else{
      cout << "NO" << endl;
    }
  }
  return (0);
}

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

int main(){
    int n,tmp,a = 0,b = 0;
    bool judge;
    cin >> n;
    while(n--){
        judge = true;
        for(int i=0;i<10;i++){
            cin >> tmp;
            if(tmp > a) a = tmp;
            else if(tmp > b) b = tmp;
            else judge = false;
        }
        if(judge) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

C++: #include <cstdio>

int a[10];

int main(int argc, const char * argv[]) {
    int T;
    scanf("%d", &T);
    while (T--) {
        bool ans = true;
        for (int i = 0; i < 10; i++) {
            scanf("%d", &a[i]);
        }
        int l, r;
        l = r = 0;
        for (int i = 0; i < 10; i++) {
            if (a[i] > l) {
                l = a[i];
            } else if (a[i] > r) {
                r = a[i];
            } else {
                ans = false;
                break;
            }
        }
        printf("%s\n", ans ? "YES" : "NO");
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
#include<cstdio>
#include<string.h>
int a[50][11];
int b[50][11],c[50][11];
//int flag[100][11];
int by = 0,cy = 0;
int lb ;
int lc ;
void dfs(int x,int y){
    if(y<10){
    if(b[x][by]<a[x][y]){
        b[x][++by]=a[x][y++];
        ++lb;
    }
    else if(c[x][cy]<a[x][y]){
        c[x][++cy] = a[x][y++];
        ++lc;
    }
    // y +=1;

    dfs(x,y);}
}
void solve(){
    int n;
cin>>n;
        while(n--){
           
    for(int i = 0; i < n; i++)
            for(int j = 0; j < 10; j++)
                cin>>a[i][j];
     for(int i = 0; i < n; i++){
                dfs(i,0);
                if(lb+lc==10)
            printf("YES\n");
        else
            printf("NO\n");}
    }
}


int main(){
solve();
return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
int N;
int ball[10];
int l[20],r[20];
bool flag;
void DFS(int i,int ll,int rr)//i:当前所放球的序号 ll:左边该第ll位放球 rr:右边该第rr位放球
{
    if(i>=10)
        flag=1;
    if(ball[i]>l[ll-1])
    {
        l[ll]=ball[i];
        DFS(i+1,ll+1,rr);
    }
    if(ball[i]>r[rr-1])
    {
        r[rr]=ball[i];
        DFS(i+1,ll,rr+1);
    }
}
int main()
{
    scanf("%d",&N);
    while(N--)
    {
        memset(l,0,sizeof(l));
        memset(r,0,sizeof(r));
        for(int i=0;i<10;i++)
            scanf("%d",&ball[i]);
        flag=0;
        DFS(0,1,1);
        if(flag)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}

C++: #include <stdio.h>

int main()
{
	int N, ball[10], B[10], C[10], b, c, k;

	scanf("%d", &N);

	for (int i = 0; i < 2; i++){
		scanf("%d %d %d %d %d %d %d %d %d %d", &ball[0], &ball[1], &ball[2], &ball[3], &ball[4], &ball[5], &ball[6], &ball[7], &ball[8], &ball[9]);

		b = 0;
		c = 0;
		k = 0;
		for (int j = 0; j < 10; j++){
			if(b < ball[j]) b = ball[j];
			else if(c < ball[j]) c = ball[j];
			else {k = 1; break;}
		}

		if(k == 0) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}