模拟一下就出来了,坐标的变换
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int a[505][505];
void fun(int x,int y,int r,int z){
int i,j;
if(z == 0){
for(i = 1; i <= r; ++i){
for(j = -i; j < i; ++j){
swap(a[x-i][y+j],a[x+j][y+i]);
swap(a[x+i][y-j],a[x-i][y+j]);
swap(a[x-i][y+j],a[x-j][y-i]);
}
}
}
else{
for(i = 1; i <= r; ++i){
for(j = -i; j < i; ++j){
swap(a[x-i][y+j],a[x-j][y-i]);
swap(a[x-i][y+j],a[x+i][y-j]);
swap(a[x-i][y+j],a[x+j][y+i]);
}
}
}
}
int main(){
int n,m;
cin >> n >> m;
int i,j;
int num = 0;
for(i = 1; i <= n; ++i)
for(j = 1; j <= n; ++j)
a[i][j] = ++num;
int x,y,z,r;
while(m--){
cin >> x >> y >> r >> z;
fun(x,y,r,z);
}
for(i = 1; i <= n; ++i){
for(j = 1; j < n; ++j)
cout << a[i][j] << " ";
cout << a[i][j] << endl;
}
return 0;
}