1 条题解
-
0
#include <iostream> #include <iostream> #include <algorithm> #include <numeric> #include <vector> #include <deque> #include <array> #include <set> #include <map> #include <iomanip> #include <cmath> #include <cstdio> #include <climits> #include <string> #include <cstring> using namespace std; struct cmp { bool operator()(int a, int b) { return a > b; } }; template<class T> int length(T &array) { return sizeof(array) / sizeof(array[0]); } bool is_prime[100007]; void ai() { for (int i = 2; i <= 100000; i++) { is_prime[i] = 1; } for (int i = 2; i <= 100000; i++) { if (is_prime[i]) { for (int j = 2 * i; j <= 100000; j += i) { is_prime[j] = 0; } } } } int numberInversion(int x) { int num = 0; while (x != 0) { num = num * 10 + x % 10; x /= 10; } return num; } int n; //90度 void change1(char a[11][11], char c[11][11]) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { c[i][j] = a[n - j - 1][i]; } } //a变为c for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = c[i][j]; } } } //水平翻转 void change2(char a[11][11], char c[11][11]) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { c[i][j] = a[i][n - j - 1]; } } //a变为c for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { a[i][j] = c[i][j]; } } } bool equality(char b[11][11], char c[11][11]) { for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (b[i][j] != c[i][j]) { return false; } } } return true; } int main() { char a[11][11], b[11][11], c[11][11]; scanf("%d", &n); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> a[i][j]; } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { cin >> b[i][j]; } } for (int i = 1; i <= 3; i++) { change1(a, c); if (equality(b, c)) { printf("%d", i); return 0; } } //恢复 change1(a, c); //水平 change2(a, c); if (equality(b, c)) { printf("%d", 4); return 0; } for (int i = 1; i <= 3; i++) { change1(a, c); if (equality(b, c)) { printf("%d", 5); return 0; } } //恢复 change1(a, c); if (equality(b, c)) { printf("%d", 6); return 0; } printf("%d", 7); return 0; }
- 1
信息
- ID
- 1591
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 19
- 已通过
- 8
- 上传者