+ - + - + - + - + - + - + | q | r | a | b | u | v | + - + - + - + - + - + - + | s | t | c | d | w | x | + - + - + - + - + - + - + | e | f | + - + - + | g | h | + - + - + | i | j | + - + - + | k | l | + - + - + | m | n | + - + - + | o | p | + - + - +
有点恶心的模拟题
#include
#include
#include
#include
#include
using namespace std;
const int INF=1e9+7;
const int MAXN=1000+10;
int a[7][5];
int b[7][5];
bool check(){
int ok=1;
for(int i=1;i<=6&&ok;i++){
for(int j=1;j<=3;j++){
if(b[i][j]!=b[i][j+1]){
ok=0;
break;
}
}
if(ok==0)
break;
}
return ok;
}
void change(int x){
for(int i=1;i<=6;i++){
for(int j=1;j<=4;j++){
b[i][j]=a[i][j];
}
}
if(x==0)
return;
if(x==1){
int tx=b[2][1],ty=b[2][2];
b[2][1]=b[5][2],b[2][2]=b[5][4];
b[5][2]=b[4][4],b[5][4]=b[4][3];
b[4][3]=b[6][3],b[4][4]=b[6][1];
b[6][3]=tx,b[6][1]=ty;
}else if(x==2){
int tx=b[2][1],ty=b[2][2];
b[2][1]=b[6][3],b[2][2]=b[6][1];
b[6][3]=b[4][3],b[6][1]=b[4][4];
b[4][4]=b[5][2],b[4][3]=b[5][4];
b[5][2]=tx,b[5][4]=ty;
}else if(x==3){
int tx=b[2][1],ty=b[2][3];
b[2][1]=b[3][1],b[2][3]=b[3][3];
b[3][1]=b[4][1],b[3][3]=b[4][3];
b[4][1]=b[1][1],b[4][3]=b[1][3];
b[1][1]=tx,b[1][3]=ty;
}else if(x==4){
int tx=b[2][1],ty=b[2][3];
b[2][1]=b[1][1],b[2][3]=b[1][3];
b[1][1]=b[4][1],b[1][3]=b[4][3];
b[4][1]=b[3][1],b[4][3]=b[3][3];
b[3][1]=tx,b[3][3]=ty;
}else if(x==5){
int tx=b[1][1],ty=b[1][2];
b[1][1]=b[5][1],b[1][2]=b[5][2];
b[5][2]=b[3][3],b[5][1]=b[3][4];
b[3][3]=b[6][2],b[3][4]=b[6][1];
b[6][2]=ty,b[6][1]=tx;
}else{
int tx=b[1][1],ty=b[1][2];
b[1][1]=b[6][1],b[1][2]=b[6][2];
b[6][2]=b[3][3],b[6][1]=b[3][4];
b[3][3]=b[5][2],b[3][4]=b[5][1];
b[5][2]=ty,b[5][1]=tx;
}
}
int main(){
int t;
scanf("%d",&t);
while(t--){
for(int i=1;i<=6;i++){
for(int j=1;j<=4;j++){
scanf("%d",&a[i][j]);
}
}
int ok=0;
for(int i=0;i<=6;i++){
change(i);
ok=check();
if(ok)
break;
}
if(ok)
puts("YES");
else
puts("NO");
}
}
/*
1
1 4 1 4
2 1 2 1
3 2 3 2
4 3 4 3
5 5 5 5
6 6 6 6
*/