Language: C++

#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;

class FC{
public:
    int p[31];
    int n;
        
    bool is_over(){
     	return p[1]==p[2] && p[2]==p[3} && p[3]==p[4] && p[4]==p[5] &&
        	p[5]==p[6] && p[6]==p[7} && p[7]==p[8] && p[8]==p[9] &&
        	p[10]==p[11} && p[11]==p[12] &&
      		p[13]==p[14} && p[14]==p[15] &&
      		p[16]==p[17} && p[17]==p[18] &&
      		p[19]==p[20} && p[20]==p[21];
     }
          
    void rot1()
    {
        swap(p[7], p[22]);  swap(p[8], p[23]);  swap(p[9], p[24]);
        swap(p[10], p[12]);  swap(p[13], p[18]);
    }
 
    void rot2()
    {
        swap(p[1], p[28]);  swap(p[2], p[29]);  swap(p[3], p[30]);
        swap(p[19], p[21]);  swap(p[15], p[16]);
    }
 
    void rot3()
    {
        swap(p[1], p[24]);  swap(p[4], p[27]);  swap(p[7], p[30]);
        swap(p[16], p[18]);  swap(p[10], p[21]);
    }
 
    void rot4()
    {
        swap(p[3], p[22]);  swap(p[6], p[25]);  swap(p9], p[28]);
        swap(p[13], p[15]);  swap(p[12], p[19]);
    }
};
 
int main()
{
    int N;
    cin >> N;
 
    for(int i=0; i<N; i++){
        State now;
        for(int j=1; j<=30; j++){
            cin >> now.p[j];
        }
        now.n = 0;
 
        queue<State> que;
        que.push(now);
 
        while(!que.empty()){
            now = que.front();
            que.pop();
 
            if(now.is_over()){
                cout << now.n << endl;
                break;
            }
 
            State nex1 = now;  nex1.rot1();  nex1.n++;  que.push(nex1);
            State nex2 = now;  nex2.rot2();  nex2.n++;  que.push(nex2);
            State nex3 = now;  nex3.rot3();  nex3.n++;  que.push(nex3);
            State nex4 = now;  nex4.rot4();  nex4.n++;  que.push(nex4);
        }
    }
 
    return 0;
}  

Compiler output:
a.cc:12:44: error: ISO C++ forbids declaration of 'p' with no type [-fpermissive]
   12 |         return p[1]==p[2] && p[2]==p[3} && p[3]==p[4] && p[4]==p[5] &&
      |                                            ^
a.cc:12:44: error: declaration of 'p' as array of references
a.cc:12:47: error: expected ';' at end of member declaration
   12 |         return p[1]==p[2] && p[2]==p[3} && p[3]==p[4] && p[4]==p[5] &&
      |                                               ^
      |                                                ;
a.cc:12:48: error: expected unqualified-id before '==' token
   12 |         return p[1]==p[2] && p[2]==p[3} && p[3]==p[4] && p[4]==p[5] &&
      |                                                ^~
a.cc:13:41: error: expected ';' after class definition
   13 |                 p[5]==p[6] && p[6]==p[7} && p[7]==p[8] && p[8]==p[9] &&
      |                                         ^
      |                                         ;
a.cc: In member function 'bool FC::is_over()':
a.cc:12:39: error: expected ']' before '}' token
   12 |         return p[1]==p[2] && p[2]==p[3} && p[3]==p[4] && p[4]==p[5] &&
      |                                       ^
a.cc:12:39: error: expected ';' before '}' token
a.cc: At global scope:
a.cc:13:49: error: expected constructor, destructor, or type conversion before '==' token
   13 |                 p[5]==p[6] && p[6]==p[7} && p[7]==p[8] && p[8]==p[9] &&
      |                                                 ^~
a.cc:14:28: error: expected declaration before '}' token
   14 |                 p[10]==p[11} && p[11]==p[12] &&
      |                            ^
a.cc:14:38: error: expected constructor, destructor, or type conversion before '==' token
   14 |                 p[10]==p[11} && p[11]==p[12] &&
      |                                      ^~
a.cc:15:28: error: expected declaration before '}' token
   15 |                 p[13]==p[14} && p[14]==p[15] &&
      |                            ^
a.cc:15:38: error: expected constructor, destructor, or type conversion before '==' token
   15 |                 p[13]==p[14} && p[14]==p[15] &&
      |                                      ^~
a.cc:16:28: error: expected declaration before '}' token
   16 |                 p[16]==p[17} && p[17]==p[18] &&
      |                            ^
a.cc:16:38: error: expected constructor, destructor, or type conversion before '==' token
   16 |                 p[16]==p[17} && p[17]==p[18] &&
      |                                      ^~
a.cc:17:28: error: expected declaration before '}' token
   17 |                 p[19]==p[20} && p[20]==p[21];
      |                            ^
a.cc:17:38: error: expected constructor, destructor, or type conversion before '==' token
   17 |                 p[19]==p[20} && p[20]==p[21];
      |                                      ^~
a.cc:18:6: error: expected declaration before '}' token
   18 |      }
      |      ^
a.cc: In function 'void rot1()':
a.cc:22:14: error: 'p' was not declared in this scope
   22 |         swap(p[7], p[22]);  swap(p[8], p[23]);  swap(p[9], p[24]);
      |              ^
a.cc: In function 'void rot2()':
a.cc:28:14: error: 'p' was not declared in this scope
   28 |         swap(p[1], p[28]);  swap(p[2], p[29]);  swap(p[3], p[30]);
      |              ^
a.cc: In function 'void rot3()':
a.cc:34:14: error: 'p' was not declared in this scope
   34 |         swap(p[1], p[24]);  swap(p[4], p[27]);  swap(p[7], p[30]);
      |              ^
a.cc: In function 'void rot4()':
a.cc:40:14: error: 'p' was not declared in this scope
   40 |         swap(p[3], p[22]);  swap(p[6], p[25]);  swap(p9], p[28]);
      |              ^
a.cc:40:54: error: 'p9' was not declared in this scope
   40 |         swap(p[3], p[22]);  swap(p[6], p[25]);  swap(p9], p[28]);
      |                                                      ^~
a.cc: At global scope:
a.cc:43:1: error: expected declaration before '}' token
   43 | };
      | ^
a.cc: In function 'int main()':
a.cc:51:9: error: 'State' was not declared in this scope
   51 |         State now;
      |         ^~~~~
a.cc:53:20: error: 'now' was not declared in this scope
   53 |             cin >> now.p[j];
      |                    ^~~
a.cc:55:9: error: 'now' was not declared in this scope
   55 |         now.n = 0;
      |         ^~~
a.cc:57:20: error: template argument 2 is invalid
   57 |         queue<State> que;
      |                    ^
a.cc:58:13: error: request for member 'push' in 'que', which is of non-class type 'int'
   58 |         que.push(now);
      |             ^~~~
a.cc:60:20: error: request for member 'empty' in 'que', which is of non-class type 'int'
   60 |         while(!que.empty()){
      |                    ^~~~~
a.cc:61:23: error: request for member 'front' in 'que', which is of non-class type 'int'
   61 |             now = que.front();
      |                       ^~~~~
a.cc:62:17: error: request for member 'pop' in 'que', which is of non-class type 'int'
   62 |             que.pop();
      |                 ^~~
a.cc:69:18: error: expected ';' before 'nex1'
   69 |             State nex1 = now;  nex1.rot1();  nex1.n++;  que.push(nex1);
      |                  ^~~~~
      |                  ;
a.cc:69:32: error: 'nex1' was not declared in this scope
   69 |             State nex1 = now;  nex1.rot1();  nex1.n++;  que.push(nex1);
      |                                ^~~~
a.cc:69:61: error: request for member 'push' in 'que', which is of non-class type 'int'
   69 |             State nex1 = now;  nex1.rot1();  nex1.n++;  que.push(nex1);
      |                                                             ^~~~
a.cc:70:18: error: expected ';' before 'nex2'
   70 |             State nex2 = now;  nex2.rot2();  nex2.n++;  que.push(nex2);
      |                  ^~~~~
      |                  ;
a.cc:70:32: error: 'nex2' was not declared in this scope
   70 |             State nex2 = now;  nex2.rot2();  nex2.n++;  que.push(nex2);
      |                                ^~~~
a.cc:70:61: error: request for member 'push' in 'que', which is of non-class type 'int'
   70 |             State nex2 = now;  nex2.rot2();  nex2.n++;  que.push(nex2);
      |                                                             ^~~~
a.cc:71:18: error: expected ';' before 'nex3'
   71 |             State nex3 = now;  nex3.rot3();  nex3.n++;  que.push(nex3);
      |                  ^~~~~
      |                  ;
a.cc:71:32: error: 'nex3' was not declared in this scope
   71 |             State nex3 = now;  nex3.rot3();  nex3.n++;  que.push(nex3);
      |                                ^~~~
a.cc:71:61: error: request for member 'push' in 'que', which is of non-class type 'int'
   71 |             State nex3 = now;  nex3.rot3();  nex3.n++;  que.push(nex3);
      |                                                             ^~~~
a.cc:72:18: error: expected ';' before 'nex4'
   72 |             State nex4 = now;  nex4.rot4();  nex4.n++;  que.push(nex4);
      |                  ^~~~~
      |                  ;
a.cc:72:32: error: 'nex4' was not declared in this scope
   72 |             State nex4 = now;  nex4.rot4();  nex4.n++;  que.push(nex4);
      |                                ^~~~
a.cc:72:61: error: request for member 'push' in 'que', which is of non-class type 'int'
   72 |             State nex4 = now;  nex4.rot4();  nex4.n++;  que.push(nex4);
      |                                                             ^~~~