This time Sengang cup G topic
I played for more than an hour , finally ac It's over ;
I vomited
Title Description
There is a card on the table , A card is a card N * N Grid of , Each grid contains an integer on both sides . At the beginning, the card is put face up on the table , Please judge the execution
The number distribution of the grid in the card after the following operations ：
operation 1：1 x y val It means that the first x that 's ok , The third y Change the column number to val, Only the current face up element is modified .(1 <= x, y <= n)
operation 2：2 x y Put the card in the second place x Line and section y Row exchange .(x, i) <–> (y, i) among (1 <= i <= n).(1 <= x, y <= n)
operation 3：3 x y Put the card in the second place x Lieheti x Column switching .(i, x) <–> (i, y) among (1 <= i <= n).(1 <= x, y <= n)
operation 4：4 Flip the card , From positive to negative , The opposite will become the positive .
operation 5：5 Rotate the card clockwise 90 degree .
operation 6：6 Rotate the card clockwise 180 degree .
operation 7：7 Rotate the card clockwise 270 degree .
be careful ： Both sides of each grid are a whole , In exchange , In the process of rotation, the back element changes position with the front element .
Enter a description :
The first line of input contains two integers n, m. Indicates the size of the card grid and the number of operations .
And then follow n that 's ok , Per line n An integer , Indicates the front of the card n * n grid
And then follow n that 's ok , Per line n An integer , Indicates the reverse side of the card n * n grid .
And then follow m that 's ok , One operation instruction per line .
Output description :
stay m After the first operation instruction is executed , Output answer .
Before output n that 's ok , Per line n An integer , Indicates the front of the card .
And then output n that 's ok , Per line n An integer , Indicates the reverse side of the card .
Examples 1
input
copy
3 7
1 2 3
4 5 6
7 8 9
7 8 9
4 5 6
1 2 3
1 1 3 0
2 1 3
3 2 3
4
5
6
7
output
copy
8 9 7
5 6 4
2 3 1
2 0 1
5 6 4
8 9 7
explain
positive the other side
1 2 3 7 8 9
4 5 6 4 5 6
7 8 9 1 2 3
In execution 1 1 3 0 after ：
positive the other side
1 2 0 7 8 9
4 5 6 4 5 6
7 8 9 1 2 3
In execution 2 1 3 after ：
7 8 9 1 2 3
4 5 6 4 5 6
1 2 0 7 8 9
In execution 3 2 3 after ：
7 9 8 1 3 2
4 6 5 4 6 5
1 0 2 7 9 8
In execution 4 after ：
1 3 2 7 9 8
4 6 5 4 6 5
7 9 8 1 0 2
In execution 5 after ：
7 4 1 1 4 7
9 6 3 0 6 9
8 5 2 2 5 8
In execution 6 after ：
2 5 8 8 5 2
3 6 9 9 6 0
1 4 7 7 4 1
In execution 7 after ：
8 9 7 2 0 1
5 6 4 5 6 4
2 3 1 8 9 7
remarks :
1 <= n, m, val <= 100
The code is as follows
#include<iostream> #include<algorithm> using namespace std; const int N=105;
int n,m; int a[N][N];// positive int b[N][N];// the other side // Scheme 1 void fan_1(int x,int y,int val)
{ a[x][y]=val; } // Scheme 2 void fan_2(int x,int y){ int c[N];int d[N]; for(int i=0;i
<n;i++) c[i]=a[x][i],d[i]=b[x][i]; for(int i=0;i<n;i++) a[x][i]=a[y][i],b[x][i]=
b[y][i]; for(int i=0;i<n;i++) a[y][i]=c[i],b[y][i]=d[i]; } // Scheme 3 void fan_3(int
x,int y){ int c[N];int d[N]; for(int i=0;i<n;i++) c[i]=a[i][x],d[i]=b[i][x]; for
(int i=0;i<n;i++) a[i][x]=a[i][y],b[i][x]=b[i][y]; for(int i=0;i<n;i++) a[i][y]=
c[i],b[i][y]=d[i]; } void fan_4(){ int c[N][N]; for(int i=0;i<n;i++) for(int j=0
;j<n;j++) c[i][j]=a[i][j]; for(int i=0;i<n;i++) for(int j=0;j<n;j++) a[i][j]=b[i
][j]; for(int i=0;i<n;i++) for(int j=0;j<n;j++) b[i][j]=c[i][j]; } // Scheme 5 void
fan_5(){ int c[N][N];int d[N][N]; for(int i=0;i<n;i++) for(int j=0;j<n;j++){ c[i
][j]=a[n-j-1][i]; d[i][j]=b[n-j-1][i]; } for(int i=0;i<n;i++) for(int j=0;j<n;j
++){ a[i][j]=c[i][j]; b[i][j]=d[i][j]; } } // Scheme 6 void fan_6(){ int c[N][N];int d
[N][N]; for(int i=0;i<n;i++) for(int j=0;j<n;j++){ c[i][j]=a[n-i-1][n-j-1]; d[i]
[j]=b[n-i-1][n-j-1]; } for(int i=0;i<n;i++) for(int j=0;j<n;j++){ a[i][j]=c[i][j
]; b[i][j]=d[i][j]; } } // Scheme 7 void fan_7(){ int c[N][N];int d[N][N]; for(int i=0
;i<n;i++) for(int j=0;j<n;j++){ c[i][j]=a[j][n-i-1]; d[i][j]=b[j][n-i-1]; } for(
int i=0;i<n;i++) for(int j=0;j<n;j++){ a[i][j]=c[i][j]; b[i][j]=d[i][j]; } } int
main(){ cin>>n>>m; // Input positive and negative numbers for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j
]; for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>b[i][j]; // Perform the operation for(int i=0;i<
m;i++){ int f_a; cin>>f_a;// Implementation scheme input // What's the point swith Or cascade , I choose swith; int x,y,val; switch
(f_a){ case 1: cin>>x>>y>>val;fan_1(x-1,y-1,val);break; case 2: cin>>x>>y;fan_2(
x-1,y-1);break; case 3: cin>>x>>y;fan_3(x-1,y-1);break; case 4: fan_4();break;
case 5: fan_5();break; case 6: fan_6();break; case 7: fan_7();break; } } // Output front
for(int i=0;i<n;i++) for(int j=0;j<n;j++) cout<<a[i][j]<<(j!=n-1?" ":"\n");
// Output negative for(int i=0;i<n;i++) for(int j=0;j<n;j++) cout<<b[i][j]<<(j!=n-1?" ":"\n"
); return 0; }
A cute new helpless , This is the only stupid way 0.0
It's not the president who wants me to fight
I don't want to fight

Technology
Daily Recommendation
views 2