Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- #include<cstring>
- using namespace std;
- int main()
- {
- int R,C,M;
- while(cin>>R>>C>>M)
- {
- int in[R][C];
- int change[C][R];
- for(int i=0;i<R;i++)
- {
- for(int j=0;j<C;j++)
- {
- cin>>in[i][j];
- }
- }
- int type=0;
- int work[M];
- for(int i=0;i<M;i++)
- cin>>work[i];
- /*
- cout<<"work:";
- for(int i=0;i<M;i++)
- {
- cout<<work[i];
- }
- cout<<endl;
- */
- for(int i=0;i<M;i++)
- {
- int n=work[M-i-1];
- if(n==0)
- {
- type++;
- type%=2;
- if(type==0)
- {
- for(int j=0;j<R;j++)
- {
- for(int k=0;k<C;k++)
- {
- in[j][k]=change[k][R-j-1];
- }
- }
- }
- else
- {
- for(int j=0;j<C;j++)
- {
- for(int k=0;k<R;k++)
- {
- change[j][k]=in[k][C-j-1];
- }
- }
- }
- }
- else
- {
- int reverse[R][C];
- for(int j=0;j<R;j++)
- {
- for(int k=0;k<C;k++)
- {
- reverse[j][k]=in[R-j-1][k];
- }
- }
- for(int j=0;j<R;j++)
- {
- for(int k=0;k<C;k++)
- {
- in[j][k]=reverse[j][k];
- }
- }
- int reverse2[C][R];
- for(int j=0;j<C;j++)
- {
- for(int k=0;k<R;k++)
- {
- reverse2[j][k]=change[C-j-1][k];
- }
- }
- for(int j=0;j<C;j++)
- {
- for(int k=0;k<R;k++)
- {
- change[j][k]=reverse2[j][k];
- }
- }
- }
- /*
- cout<<"////////////////"<<endl;
- if(type==0)
- {
- cout<<R<<" "<<C<<endl;
- for(int i=0;i<R;i++)
- {
- for(int j=0;j<C;j++)
- {
- cout<<in[i][j];
- if(j!=C-1)
- cout<<" ";
- }
- cout<<endl;
- }
- }
- else
- {
- cout<<C<<" "<<R<<endl;
- for(int i=0;i<C;i++)
- {
- for(int j=0;j<R;j++)
- {
- cout<<change[i][j];
- if(j!=R-1)
- cout<<" ";
- }
- cout<<endl;
- }
- }
- cout<<"////////////////"<<endl;
- */
- }
- if(type==0)
- {
- cout<<R<<" "<<C<<endl;
- for(int i=0;i<R;i++)
- {
- for(int j=0;j<C;j++)
- {
- cout<<in[i][j];
- if(j!=C-1)
- cout<<" ";
- }
- cout<<endl;
- }
- }
- else
- {
- cout<<C<<" "<<R<<endl;
- for(int i=0;i<C;i++)
- {
- for(int j=0;j<R;j++)
- {
- cout<<change[i][j];
- if(j!=R-1)
- cout<<" ";
- }
- cout<<endl;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment