Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
一直TLE,郁闷呀!!#include <iostream> #include <fstream> #include <stdio.h> using namespace std; int m,n; char arr[310][310]; void swap(int &a,int &b){ int tmp=a; a=b; b=tmp; } void func(char c,char a[][310]){ int i,j,k; char tmp[310][310]; if(c=='1'){ for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ tmp[j][i]=a[i][j]; } } swap(m,n); // memcpy(a,tmp,sizeof(tmp)); for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ a[i][j]=tmp[i][j]; } } }else if(c=='2'){ for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ tmp[n+1-j][m+1-i]=a[i][j]; } } swap(n,m); for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ a[i][j]=tmp[i][j]; } } }else if(c=='H'){ for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ tmp[m-i+1][j]=a[i][j]; } } for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ a[i][j]=tmp[i][j]; } } }else if(c=='V'){ for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ tmp[i][n-j+1]=a[i][j]; } } for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ a[i][j]=tmp[i][j]; } } }else if(c=='A'||c=='B'||c=='C'){ int tmpn=c-'A'; for(k=0;k<=tmpn;k++){ for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ tmp[j][m-i+1]=a[i][j]; } } swap(m,n); for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ a[i][j]=tmp[i][j]; } } } }else if(c=='X'||c=='Y'||c=='Z'){ int tmpn=c-'X'; for(k=0;k<=tmpn;k++){ for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ tmp[n-j+1][i]=a[i][j]; } } swap(m,n); for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ a[i][j]=tmp[i][j]; } } } } /* for(i=1;i<=m;i++){ cout<<tmp[i]<<endl; } */ // cout<<m<<" "<<n<<endl; } int main(){ // ifstream cin("data.txt"); // freopen("data.txt","r",stdin); //cin>>m>>n; scanf("%d%d",&m,&n); int i,j,k; for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ cin>>arr[i][j]; } } char command[100100]; scanf("%s",command); int len=strlen(command); for(i=0;i<len;i++){ func(command[i],arr); } cout<<m<<" "<<n<<endl; for(i=1;i<=m;i++){ for(j=1;j<=n;j++){ cout<<arr[i][j]; } cout<<endl; } return 1; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator