P1205 方块转换 57分外加一个看不懂的样例
  • 板块学术版
  • 楼主credente
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/9/16 12:00
  • 上次更新2024/9/16 15:56:43
查看原帖
P1205 方块转换 57分外加一个看不懂的样例
1285014
credente楼主2024/9/16 12:00

rt

#include<bits/stdc++.h>
using namespace std;

char a[15][15];
char s[15][15];
char b[15][15];

int n;
int ans=0;
int sum;

bool work()
{
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(s[i][j]!=b[i][j])
				return false;
		}
	}
	return true;
}

bool work1()
{
	int t=n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			s[j][t]=a[i][j];
		}
		t--;
	}
	if(work())
		return true;
	return false;
}

bool work2()
{
	int t=n;
	for(int i=1;i<=n;i++)
	{	
		int q=n;
		for(int j=1;j<=n;j++)
		{
			s[t][q]=a[i][j];
			q--;
		}
		t--;
	}
	if(work())
		return true;
	return false;
}

bool work3()
{
	int t=1;
	for(int i=1;i<=n;i++)
	{
		int q=n;
		for(int j=1;j<=n;j++)
		{
			s[q][t]=a[i][j];
			q--;
		}
		t++;
	}
	if(work())
		return true;
	return false;
}

bool work4()
{
	int t=1;
	for(int i=1;i<=n;i++)
	{
		int q=n;
		for(int j=1;j<=n;j++)
		{
			s[t][q]=a[i][j];
			q--;
		}
		t++;
	}
	if(work())
		return true;
	return false;
}

bool work5()
{
	work4();
	if(work1()||work3()||work2())
		return true;
	return false;	
}

int main()
{
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin >> a[i][j];
			s[i][j]=a[i][j];
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin >> b[i][j];
		}
	}
	if(work())
	{
		cout << 6;
		return 0;
	}
	if(work1())
	{
		cout << 1;
		return 0;
	}
	if(work2())
	{
		cout << 2;
		return 0;
	}
	if(work3())
	{
		cout << 3;
		return 0;
	}
	if(work4())
	{
		cout << 4;
		return 0;
	}
	if(work5())
	{
		cout << 5;
		return 0;
	}
	else
		cout << 7;
	return 0;
}
5
-@@@-
-@@--
-@---
-----
-----
-----
----@
---@@
--@@@
-----
# 为什么输出是5?我的代码输出是7
2024/9/16 12:00
加载中...