为什么就只能对一个,其他全爆红
查看原帖
为什么就只能对一个,其他全爆红
1342211
H910695楼主2025/1/26 19:13
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool way1(vector<vector<int>>list3, vector<vector<int>>list4, int m) {
    vector<vector<int>> list5(m, vector<int>(m));
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            list5[j][m - 1 - i] = list3[i][j];
        }
    }
    
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            if(list5[i][j] != list4[i][j]){
            	return false;
			}
        }
    }
    return true;
}

bool way2(vector<vector<int>>list3, vector<vector<int>>list4, int m) {
    vector<vector<int>> list5(m, vector<int>(m));
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            list5[m-1-i][m-1-j] = list3[i][j];
        }
    }
    
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            if(list5[i][j] != list4[i][j]){
            	return false;
			}
        }
    }
    return true;
}

bool way3(vector<vector<int>>list3, vector<vector<int>>list4, int m) {
    vector<vector<int>> list5(m, vector<int>(m));
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            list5[m-1-i][m-1-j] = list3[i][j];
        }
    }
    
    vector<vector<int>> list6(m, vector<int>(m));
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            list6[j][m - 1 - i] = list5[i][j];
        }
    }
    
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            if(list6[i][j] != list4[i][j]){
            	return false;
			}
        }
    }
    return true;
}

bool way4(vector<vector<int>>list3, vector<vector<int>>list4, int m) {
    vector<vector<int>> list5(m, vector<int>(m));
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            list5[i][m-1-j] = list3[i][j];
        }
    }
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            if(list5[i][j] != list4[i][j]){
            	return false;
			}
        }
    }
    return true;
}

bool way5(vector<vector<int>>list3, vector<vector<int>>list4, int m) {
	vector<vector<int>>list5(m,vector<int>(m));
	for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            list5[i][m-1-j] = list3[i][j];
        }
    }
    if(way3(list5, list4, m) || way2(list5, list4, m) || way1(list5, list4, m)) {
        return true;
    }
    return false;
}

bool way6(vector<vector<int>>list3, vector<vector<int>>list4, int m) {
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < m; ++j){
            if(list3[i][j] != list4[i][j]) return false;
        }
    }
    return true;
}

int main() 
{
    int n;
    cin >> n;
    cin.ignore(); // 忽略换行符

    vector<vector<int>> list1(n, vector<int>(n));
    vector<vector<int>> list2(n, vector<int>(n));

    // 读取原来的图形
    for(int i = 0; i < n; ++i){
        string line;
        getline(cin, line);
        for(int j = 0; j < n; ++j)
            list1[i][j] = (line[j] == '@') ? 1 : 0;
    }

    // 读取现在的图形
    for(int i = 0; i < n; ++i){
        string line;
        getline(cin, line);
        for(int j = 0; j < n; ++j)
            list2[i][j] = (line[j] == '@') ? 1 : 0;
    }

    if(way1(list1, list2, n)) cout << 1;
    else if(way2(list1, list2, n)) cout << 2;
    else if(way3(list1, list2, n)) cout << 3;
    else if(way4(list1, list2, n)) cout << 4;
    else if(way5(list1, list2, n)) cout << 5;
    else if(way6(list1, list2, n)) cout << 6;
    else cout << 7;

    return 0;
}
2025/1/26 19:13
加载中...