硬写 2,7WA,求解
查看原帖
硬写 2,7WA,求解
1026350
Suboil楼主2023/7/18 23:11
#include <bits/stdc++.h>
using namespace std;

int n;
string str[12],ans[12],com[12];

bool compare() {
    int cnt = 0;
    for(int i = 0;i < n;i++) {
        if(com[i] == ans[i]) cnt++;
    }
    return cnt == n;
}


bool change1(){
    for(int i = 0;i < n;i++) {
        string s;
        for(int j = n - 1;j >= 0;j--) {
            s += str[j][i];
        }
        ans[i] = s;
    }
    return compare();
}

bool change2() {
    int idx = 0;
    for(int i = n - 1;i >= 0;i--) {
        string s;
        for(int j = n - 1;j >= 0;j--) {
            s += str[i][j];
        }
        ans[idx++] = s;
    }
    return compare();
}

bool change3(){
    int idx = 0;
    for(int i = n - 1;i >= 0;i--){
        string s;
        for(int j = 0;j < n;j++) {
            s += str[j][i];
        }
        ans[idx++] = s;
    }
    return compare();
}

bool change4(){
    int idx = 0;
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < n / 2;j++) {
            char s = str[i][j];
            str[i][j] = str[i][n - 1 - j];
            str[i][n - 1 - j] = s;
        }
        ans[idx++] = str[i];
    }

    return compare();
}

bool change5(){
    int idx = 0;
    for(int i = 0;i < n;i++) {
        for(int j = 0;j < n / 2;j++) {
            char s = str[i][j];
            str[i][j] = str[i][n - 1 - j];
            str[i][n - 1 - j] = s;
        }
    }


    return change1() || change2() || change3();
}

bool change6(){

    for(int i = 0;i < n;i++) {
        ans[i] = str[i];
    }
    return compare();
}

int main(){
    cin >> n;
    for(int i = 0;i < n;i++) cin >> str[i];

    for(int i = 0;i < n;i++) cin >> com[i];


    if(change1()) {
        cout << 1 << endl;
    }else if(change2()){
        cout << 2 << endl;
    }else if(change3()) {
        cout << 3 << endl;
    }else if(change4()) {
        cout << 4 << endl;
    }else if(change5()) {
        cout << 5 << endl;
    }else if(change6()) {
        cout << 6 << endl;
    }else {
        cout << 7 << endl;
    }

    
    return 0;
}
2023/7/18 23:11
加载中...