#include #include #include #include using namespace std; char str[15]; int map[15]; int len; int vis[3][3][3][3][3][3][3][3][3][3]; int cor[3]; int flag; struct node { int m[15]; int step; }now,temp; void bfs() { queue q; for(int i=0; i<10; i++) { now.m[i] = map[i]; } vis[map[0]][map[1]][map[2]][map[3]][map[4]][map[5]][map[6]][map[7]][map[8]][map[9]] = 1; now.step = 0; q.push(now); while(!q.empty()) { now = q.front(); q.pop(); int k; for(k=0; k= len-1) { cout< len) { map[i] = 3; } if(str[i] == 'r') map[i] = 0; else if(str[i] == 'g') map[i] = 1; else map[i] = 2; } flag = 0; bfs(); if(!flag) cout<<"No solution!"<