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:48: 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:48: error: declaration of 'p' as array of references
a.cc:12:51: 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:52: 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:47: 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:45: 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:45: error: expected ';' before '}' token
a.cc: At global scope:
a.cc:13:53: 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:36: error: expected declaration before '}' token
   14 |                         p[10]==p[11}&&p[11]==p[12]&&
      |                                    ^
a.cc:14:44: error: expected constructor, destructor, or type conversion before '==' token
   14 |                         p[10]==p[11}&&p[11]==p[12]&&
      |                                            ^~
a.cc:15:36: error: expected declaration before '}' token
   15 |                         p[13]==p[14}&&p[14]==p[15]&&
      |                                    ^
a.cc:15:44: error: expected constructor, destructor, or type conversion before '==' token
   15 |                         p[13]==p[14}&&p[14]==p[15]&&
      |                                            ^~
a.cc:16:36: error: expected declaration before '}' token
   16 |                         p[16]==p[17}&&p[17]==p[18]&&
      |                                    ^
a.cc:16:44: error: expected constructor, destructor, or type conversion before '==' token
   16 |                         p[16]==p[17}&&p[17]==p[18]&&
      |                                            ^~
a.cc:17:36: error: expected declaration before '}' token
   17 |                         p[19]==p[20}&&p[20]==p[21];
      |                                    ^
a.cc:17:44: error: expected constructor, destructor, or type conversion before '==' token
   17 |                         p[19]==p[20}&&p[20]==p[21];
      |                                            ^~
a.cc: In function 'void rot1()':
a.cc:21:14: error: 'p' was not declared in this scope
   21 |         swap(p[7], p[22]);  swap(p[8], p[23]);  swap(p[9], p[24]);
      |              ^
a.cc: In function 'void rot2()':
a.cc:27:14: error: 'p' was not declared in this scope
   27 |         swap(p[1], p[28]);  swap(p[2], p[29]);  swap(p[3], p[30]);
      |              ^
a.cc: In function 'void rot3()':
a.cc:33:14: error: 'p' was not declared in this scope
   33 |         swap(p[1], p[24]);  swap(p[4], p[27]);  swap(p[7], p[30]);
      |              ^
a.cc: In function 'void rot4()':
a.cc:39:14: error: 'p' was not declared in this scope
   39 |         swap(p[3], p[22]);  swap(p[6], p[25]);  swap(p9], p[28]);
      |              ^
a.cc:39:54: error: 'p9' was not declared in this scope
   39 |         swap(p[3], p[22]);  swap(p[6], p[25]);  swap(p9], p[28]);
      |                                                      ^~
a.cc: At global scope:
a.cc:42:1: error: expected declaration before '}' token
   42 | };
      | ^
a.cc: In function 'int main()':
a.cc:50:9: error: 'State' was not declared in this scope
   50 |         State now;
      |         ^~~~~
a.cc:52:20: error: 'now' was not declared in this scope
   52 |             cin >> now.p[j];
      |                    ^~~
a.cc:54:9: error: 'now' was not declared in this scope
   54 |         now.n = 0;
      |         ^~~
a.cc:56:20: error: template argument 2 is invalid
   56 |         queue<State> que;
      |                    ^
a.cc:57:13: error: request for member 'push' in 'que', which is of non-class type 'int'
   57 |         que.push(now);
      |             ^~~~
a.cc:59:20: error: request for member 'empty' in 'que', which is of non-class type 'int'
   59 |         while(!que.empty()){
      |                    ^~~~~
a.cc:60:23: error: request for member 'front' in 'que', which is of non-class type 'int'
   60 |             now = que.front();
      |                       ^~~~~
a.cc:61:17: error: request for member 'pop' in 'que', which is of non-class type 'int'
   61 |             que.pop();
      |                 ^~~
a.cc:68:18: error: expected ';' before 'nex1'
   68 |             State nex1 = now;  nex1.rot1();  nex1.n++;  que.push(nex1);
      |                  ^~~~~
      |                  ;
a.cc:68:32: error: 'nex1' was not declared in this scope
   68 |             State nex1 = now;  nex1.rot1();  nex1.n++;  que.push(nex1);
      |                                ^~~~
a.cc:68:61: error: request for member 'push' in 'que', which is of non-class type 'int'
   68 |             State nex1 = now;  nex1.rot1();  nex1.n++;  que.push(nex1);
      |                                                             ^~~~
a.cc:69:18: error: expected ';' before 'nex2'
   69 |             State nex2 = now;  nex2.rot2();  nex2.n++;  que.push(nex2);
      |                  ^~~~~
      |                  ;
a.cc:69:32: error: 'nex2' was not declared in this scope
   69 |             State nex2 = now;  nex2.rot2();  nex2.n++;  que.push(nex2);
      |                                ^~~~
a.cc:69:61: error: request for member 'push' in 'que', which is of non-class type 'int'
   69 |             State nex2 = now;  nex2.rot2();  nex2.n++;  que.push(nex2);
      |                                                             ^~~~
a.cc:70:18: error: expected ';' before 'nex3'
   70 |             State nex3 = now;  nex3.rot3();  nex3.n++;  que.push(nex3);
      |                  ^~~~~
      |                  ;
a.cc:70:32: error: 'nex3' was not declared in this scope
   70 |             State nex3 = now;  nex3.rot3();  nex3.n++;  que.push(nex3);
      |                                ^~~~
a.cc:70:61: error: request for member 'push' in 'que', which is of non-class type 'int'
   70 |             State nex3 = now;  nex3.rot3();  nex3.n++;  que.push(nex3);
      |                                                             ^~~~
a.cc:71:18: error: expected ';' before 'nex4'
   71 |             State nex4 = now;  nex4.rot4();  nex4.n++;  que.push(nex4);
      |                  ^~~~~
      |                  ;
a.cc:71:32: error: 'nex4' was not declared in this scope
   71 |             State nex4 = now;  nex4.rot4();  nex4.n++;  que.push(nex4);
      |                                ^~~~
a.cc:71:61: error: request for member 'push' in 'que', which is of non-class type 'int'
   71 |             State nex4 = now;  nex4.rot4();  nex4.n++;  que.push(nex4);
      |                                                             ^~~~