魔法少女Scarlet
#include<iostream>
using namespace std;
int a[505][505], b[505][505];
int main()
{
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; i++)
a[1][i] = i;
for (int i = 2; i <= n; i++)
for (int j = 1; j <= n; j++)
a[i][j] = a[i - 1][j] + n;
int x, y, r, z;
int xt, xb;
int yl, yr;
for (int k = 0; k < m; k++)
{
cin >> x >> y >> r >> z;
xt = x - r, xb = x + r;
yl = y - r, yr = y + r;
if (z == 0)
{
for(int i=xt;i<=xb;i++)
for (int j = yl; j <= yr; j++)
{
int rx = i - x, ry = j - y;
b[x+ry][y-rx] = a[i][j];
}
for (int i = xt; i <= xb; i++)
for (int j = yl; j <= yr; j++)
a[i][j] = b[i][j];
}
else
{
for (int i = xt; i <= xb; i++)
for (int j = yl; j <= yr; j++)
{
int rx = i - x, ry = j - y;
b[x - ry][y + rx] = a[i][j];
}
for (int i = xt; i <= xb; i++)
for (int j = yl; j <= yr; j++)
a[i][j] = b[i][j];
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
cout << a[i][j] << " ";
cout << endl;
}
}