QwQ,43分……蒟蒻求助……(请做好心理准备:150行)
查看原帖
QwQ,43分……蒟蒻求助……(请做好心理准备:150行)
935012
Max6700楼主2023/5/3 16:15
#include<bits/stdc++.h>
using namespace std;

int n;

char a[1000][1000];//目标矩阵
char c[1000][1000];//初始矩阵
char b[1000][1000];//正在变的矩阵((

void w1()//操作1
{
    for(int i=1,v=n;i<=n;++i,--v)
        for(int j=1,u=1;j<=n;++j,++u)
            b[u][v]=c[i][j];
}

void w2()//操作2
{
    for(int k=1;k<=2;k++)
        for(int i=1,v=n;i<=n;++i,--v)
            for(int j=1,u=1;j<=n;++j,++u)
                b[u][v]=c[i][j];
}

void w3()//操作3
{
    for(int k=1;k<=3;k++)
        for(int i=1,v=n;i<=n;++i,--v)
            for(int j=1,u=1;j<=n;++j,++u)
                b[u][v]=c[i][j];
}

void w4()//操作4
{
    for(int i=1,u=1;i<=n;++i,++u)
        for(int j=1,v=n;j<=n;++j,--v)
            b[i][j]=c[u][v];
}

void w5_1()//操作5-1
{
    w4();
    w1();
}

void w5_2()//操作5-2
{
    w4();
    w2();
}

void w5_3()//操作5-3
{
    w4();
    w3();
}

bool w0()//判断是否相同
{
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            if(b[i][j]!=a[i][j])
                return 0;
    return 1;
}

void w()//重置
{
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            b[i][j]=c[i][j];
}

int main(){
    
    cin>>n;
    
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cin>>c[i][j];
            
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cin>>a[i][j];        
            
    w();
    w1();
    if(w0())
    {
        cout<<1;
        return 0;
    }
    
    w();
    w2();
    if(w0())
    {
        cout<<2;
        return 0;
    }
    
    w();
    w3();
    if(w0())
    {
        cout<<3;
        return 0;
    }
    
    w();
    w4();
    if(w0())
    {
        cout<<4;
        return 0;
    }
    
    w();
    w5_1();
    if(w0())
    {
        cout<<5;
        return 0;
    }
    
    w();
    w5_2();
    if(w0())
    {
        cout<<5;
        return 0;
    }
    
    w();
    w5_3();
    if(w0())
    {
        cout<<5;
        return 0;
    }
    
    w();
    if(w0())
    {
        cout<<6;
        return 0;
    }
    
    cout<<7;
    return 0;
}
2023/5/3 16:15
加载中...