Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()
	for i := 0; i < n; i++ {
		a := -1
		b := -1
		ans := true
		// それぞれの筒の一番上にあるたまの数字に着目すればよい
		for j := 0; j < 10; j++ {
			x := nextInt()
			if x > a {
				a = x
			} else if x > b {
				b = x
			} else {
				ans = false
			}
		}
		if ans {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

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

int B[11]={0};
int C[11]={0};

bool DFS(int *a,int i=0,int b=1,int c=1)
{
	bool judge=true;

	if(i==10)
		return judge;

	judge=false;

	if(B[b-1]<a[i]){
		B[b]=a[i];
		judge=DFS(a,i+1,b+1,c);
		
	}
	if(C[c-1]<a[i]){
		C[c]=a[i];
		judge=DFS(a,i+1,b,c+1);
		
	}

	return judge;
}        

int main()
{
        int N;
	int i=0;
        cin>>N;

	while(i<N){
          int A[10];
          for(int i=0;i<10;i++){
           cin>>A[i];
          }

          if(DFS(A)==true){
           cout<<"YES"<<endl;
          }
          else{
           cout<<"NO"<<endl;
          }

          i++;
        }
                
        return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int N, A[10], C = 1;

	cin >> N;

	for (int p = 0; p < N; p++)
	{
		cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4] >> A[5] >> A[6] >> A[7] >> A[8] >> A[9];

		for (int i = 0; i < 10; i++)
		{
			if (A[i] == C)
			{
				C++;
			}
		}

		for (int i = 0; i < 10; i++)
		{
			if (A[i] == C)
			{
				C++;
			}
		}

		if (C == 11)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}

		C = 1;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int n,s,right=20,left=20,ans=0,d;
	cin>>n;
	for(int p=0;p<n;p++){
		ans=0;
		right=0;
		left=0;
		for(int q=0;q<10;q++){
			//cout<<right<<"   "<<left<<endl;
			if(right>left){//rightのほうが必ず小さい
				d=right;
				right=left;
				left=d;
			}
			cin>>s;
			if(s>left){
				left=s;
			}else if(s<right){
				ans=2;
				right=s;
			}else{
				right=s;
			}
		}
		if(ans==2){
			cout<<"NO"<<endl;
		}else{
			cout<<"YES"<<endl;
		}
	}
}

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;
}