大佬们,我的代码与一ac题解几乎相同,可只能过10测试点,帮我看一下啊!
查看原帖
大佬们,我的代码与一ac题解几乎相同,可只能过10测试点,帮我看一下啊!
441726
吻你不厌楼主2021/2/2 17:18
#include<bits/stdc++.h>

using namespace std;

int main()
{
	int n,m;
	cin >> n >> m;
	
	int a[n][n];//原矩阵
	int ne[n][n];//新矩阵 
	int b = 1;
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < n;j++)
		{
			ne[i][j] = a[i][j] = b;
			b++;
		}
	}
	
	while(m--)
	{
		int x,y,r,z;
		cin >> x >> y >> r >> z;
		
		for(int i = -r;i <= r;i++)
		{
			for(int j = -r;j <= r;j++)
			{
				int nx = i;
				int ny = j;
				int t = nx;
				nx = ny;
				ny = t;	
				if(z == 0)
				{
					ny = -ny;
				}
				else if(z == 1)
				{
					nx = -nx;
				}
				ne[nx+x-1][ny+x-1] = a[x-1+i][x-1+j];
			}
		}
		for(int i = 0;i < n;i++)
		{
			for(int j = 0;j < n;j++)
			{
				a[i][j] = ne[i][j];
			}
		}
	}
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < n;j++)
		{
			cout << ne[i][j] << " ";
		}
		cout << endl;
	}
	
	return 0;
}
2021/2/2 17:18
加载中...