Language: C++

#include<stdio.h>
#include<algorithm>

using namespace std;



int main(){


	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int n[9];
		char c[9];
		int R[9];
		int G[9];
		int B[9];
		int r = 0, g = 0, b = 0;
		//?????????
		for (int j = 0; j < 9; j++){
			c[j] = 0;
			n[j] = 0;
			R[j] = 10;
			G[j] = 10;
			B[j] = 10;
		}

		//????????????	
		for (int j = 0; j < 9; j++){
			cin >> n[j];
		}
		for (int j = 0; j < 9; j++){
			cin >> c[j];
		}

		/*for (int j = 0; j < 9; j++){
			printf("%d ", n[j]);
		}
		printf("\n");
		for (int j = 0; j < 9; j++){
			printf("%c ", c[j]);
		}
		printf("\n");*/

		//?????????
		for (int j = 0; j < 9; j++){
			if (c[j] == 'R'){
				R[r] = n[j];
				r++;
			}
			else if (c[j] == 'G'){
				G[g] = n[j];
				g++;
			}
			else if (c[j] == 'B'){
				B[b] = n[j];
				b++;
			}
		}
		sort(R, R + 9);
		sort(G, G + 9);
		sort(B, B + 9);
		//??????
		int e = 0;
		
		//R
		if (R[0] != 10){
			int p=R[0];
			int f = 0;
			int d = 0;
			for (int j = 1; j < 9; j++){
				if (R[j] == 10)break;
				//printf("R %d \n", R[j]);
				if (R[j] != p + 1 && R[j]!=p){
					f = 0;
					d = 0;
					p = R[j];
				}
				else if (R[j] == p + 1){
					p++;
					f++;
				}
				else if (R[j] == p){
					d++;
				}
				if (f == 2){
					//printf("?????????:f\n");
					e++;
				}
				if (d == 2){
					//printf("?????????:d\n");
					e++;
				}
			}
		}
		//G
		if (e != 3 && G[0] != 10){
			int p = G[0];
			int f = 0;
			int d = 0;
			for (int j = 1; j < 9; j++){
				if (G[j] == 10)break;
				//printf("G %d\n", G[j]);
				if (G[j] != p + 1 && G[j] != p){
					f = 0;
					d = 0;
					p = G[j];
				}
				else if (G[j] == p + 1){
					p++;
					f++;
				}
				else if (G[j] == p){
					d++;
				}

				if (f == 2){
					//printf("?????????:f\n");
					e++;
				}
				if (d == 2){
					//printf("?????????:d\n");
					e++;
				}
			}
		}
		//B
		if (e != 3 && B[0] != 10){
			int p = B[0];
			int f = 0;
			int d = 0;
			for (int j = 1; j < 9; j++){
				if (B[j] == 10)break;
				//printf("B %d\n", B[j]);
				if (B[j] != p + 1 && B[j] != p){
					f = 0;
					d = 0;
					p = B[j];
				}
				else if (B[j] == p + 1){
					p++;
					f++;
				}
				else if (B[j] == p){
					d++;
				}

				if (f == 2){
					//printf("?????????:f\n");
					e++;
				}
				if (d == 2){
					//printf("?????????:d\n");
					e++;
				}
			}
		}
		if (e == 3)cout << 1 << endl;
		else cout << 0 << endl;
		
	}

	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'cin' was not declared in this scope
   12 |         cin >> n;
      |         ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include<algorithm>
  +++ |+#include <iostream>
    3 | 
a.cc:159:28: error: 'cout' was not declared in this scope
  159 |                 if (e == 3)cout << 1 << endl;
      |                            ^~~~
a.cc:159:28: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:159:41: error: 'endl' was not declared in this scope
  159 |                 if (e == 3)cout << 1 << endl;
      |                                         ^~~~
a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    2 | #include<algorithm>
  +++ |+#include <ostream>
    3 | 
a.cc:160:22: error: 'cout' was not declared in this scope
  160 |                 else cout << 0 << endl;
      |                      ^~~~
a.cc:160:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:160:35: error: 'endl' was not declared in this scope
  160 |                 else cout << 0 << endl;
      |                                   ^~~~
a.cc:160:35: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'