蒟蒻求助!86分代码就差这一个测试点啦
测试点2信息:
输入:
5
-@@@-
-@@--
-@---
-----
-----
-----
----@
---@@
--@@@
-----
期待输出:
5
我的输出:
7
本人代码如下
#include <bits/stdc++.h>
using namespace std;
int n;
char a[15][15],b[15][15],c[15][15],d[15][15];
void give_b_to_a(){
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
a[i][j] = b[i][j];
}
void give_a_to_d(){
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
d[i][j] = a[i][j];
}
void give_d_to_a(){
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
a[i][j] = d[i][j];
}
void give_a_to_b(){
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
b[i][j] = a[i][j];
}
bool check_bc(){
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
if (b[i][j] != c[i][j])
return 0;
return 1;
}
bool f1(){
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
b[n-j+1][i] = a[i][j];
return check_bc();
}
bool f2(){
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
b[n+1-i][n+1-j] = a[i][j];
return check_bc();
}
bool f3(){
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
b[n-i+1][n-j+1] = a[i][j];
return check_bc();
}
bool f4(){
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
b[i][n-j+1] = a[i][j];
return check_bc();
}
bool f5(){
f4();
give_b_to_a();
if (f1()||f2()||f3()) {
give_d_to_a();
return 1;
}
give_d_to_a();
return 0;
}
bool f6(){
give_a_to_b();
return check_bc();
}
void conclusion(){
if (f1()) cout << 1;
else if (f2()) cout << 2;
else if (f3()) cout << 3;
else if (f4()) cout << 4;
else if (f5()) cout << 5;
else if (f6()) cout << 6;
else cout << 7;
}
int main(){
string s;
cin >> n;
getline(cin,s);
for (int i = 1; i <= n; i++){
getline(cin,s);
for (int j = 0; j < n; j++){
a[i][j+1] = s[j];
}
}
for (int i = 1; i <= n; i++){
getline(cin,s);
for (int j = 0; j < n; j++){
c[i][j+1] = s[j];
}
}
conclusion();
return 0;
}
本蒟蒻的思维和自己的代码一样,都觉得测试点2是无法通过组合变换得到的,没有理解题目的意思,希望大佬给出解释,并指点一下代码优化, 谢谢!