pair <int,int> rotate(int x,int y) { return make_pair(y,3-x); } #include <iostream> using namespace std; char paper[4][4], pass[4][4],rPass[16],TempPaper[4][4]; int v, i, j; void check(char paper[4][4], char pass[4][4]) { for (int j = 0; j < 4; j++)// X/. { for (int i = 0; i < 4; i++) { if (paper[j][i] == 'X') { rPass[v] = pass[j][i]; v++; } } } } int main() { for (int j = 0; j < 4; j++) //paper cin { for (int i = 0; i < 4; i++) { cin >> paper[j][i]; } } for (int j = 0; j < 4; j++)//зашифрованый пароль { for (int i = 0; i < 4; i++) { cin >> pass[j][i]; } } for (int j = 0; j < 4; j++)//temp { for (int i = 0; i < 4; i++) { TempPaper[j][i] = paper[j][i]; } } check(paper, pass); for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { int t=0, y; if (j == 0) { int u = 3; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[0][y]; t++; } } if (j == 1) { int u = 2; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[1][y]; t++; } } if (j == 2) { int u = 1; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[2][y]; t++; } } if (j == 3) { int u = 0; for (y = 0; y < 4; y++) { paper[t][u] = TempPaper[3][y]; t++; } } } check(paper, pass); for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; i++) { TempPaper[j][i] = paper[j][i]; } } } return 0; } Can anybody explain me why one program can have different execution time with the same code? My friend with my code got 0.015 but I got 0.031. Oops =) I send it one more time and get 0.015. Maybe it because of server... Edited by author 22.11.2010 21:59 I had 0.031 sec, but now I finally got 0.015 sec! I've just replaced four loops with one loop. Probably depends on server current loading. My AC solution outputs extra empty line before outputing answer for the task. I think, it is not right, or I'm mistaken? That is OK. In this problem you may output any space characters before and after password. Interesting, that my solution got AC after I added \n to the end. Without \n (just 16 symbols) I have WA#1. Problems with checker? wy wrong#2 help me please!!! What is second test here my program, prompt in what a mistake. when I send to check the error of compilation writes... #include <iostream> using namespace std; void main() { const int n = 4; char Resh[n][n], OldResh[n][n], Shifr[n][n]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin » Resh[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) cin » Shifr[i][j]; for (int k = 0; k < 4; k++) { for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (Resh[i][j] == 'X') cout « Shifr[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) OldResh[i][j] = Resh[i][j]; for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) Resh[i][j] = OldResh[n - 1 - j][i]; } system("pause"); } Edited by author 24.05.2013 01:05 Code in C#!!! first of ALL just print and reverse print .... 3 times static string [,] reverse(string[,] arr) { string[,] tmp = new string [4,4];
for (int i = 0; i < 4; i++) { for (int j = 0; j < 4 ; j++) { tmp[i,j] = arr[4-j-1,i]; } } return tmp; } in this case i wrote code for 4x4 array!!! you can change your code to tmp[i,j] = arr[3-j,i] if u want reverse nxn array change all 4 to n GooD Luck! sorry for my english!! Edited by author 17.10.2012 02:39 program Project3; {$APPTYPE CONSOLE} uses SysUtils; type re=array[1..4,1..4] of char; var c,r:re ; i,j:integer; s:string; procedure vyvod(m:re) ; begin for I := 1 to 4 do for j := 1 to 4 do if m[i,j]='X' then write(r[i,j]); end; procedure perevorot(var w:re) ; var w2:re; begin vyvod(w); for I := 1 to 4 do for j := 1 to 4 do w2[i,j]:='.'; for I := 1 to 4 do if w[1,i]='X' then w2[i,4]:='X'; for I := 1 to 4 do if w[4,i]='X' then w2[i,1]:='X'; for I := 2 to 3 do if w[i,1]='X' then w2[1,5-i]:='X'; for I := 2 to 3 do if w[i,4]='X' then w2[4,i]:='X'; //rgrgr X if w[2,2]='X' then w2[2,3]:='X'; if w[2,3]='X' then w2[3,3]:='X'; if w[3,3]='X' then w2[3,2]:='X'; if w[3,2]='X' then w2[2,2]:='X'; for I := 1 to 4 do for j := 1 to 4 do w[i,j]:=w2[i,j]; end; begin for I := 1 to 4 do begin for j := 1 to 3 do begin read(c[i,j]); end; readln(c[i,j]); end; for I := 1 to 4 do begin for j := 1 to 3 do begin read(r[i,j]); end; readln(r[i,j]); end; perevorot(c); perevorot(c); perevorot(c); perevorot(c); readln;readln; end. Please give me test 5# if you have,or send me your code (oa1990_10_17@mail.ru). #include"iostream" using namespace std; void Tar(int K[][2]); int main() { int K[4][2],k=0; char s[4][5],c,ss[17]; for(int i=1;i<=4;i++) for(int j=1;j<=4;j++) { cin>>c; if(c=='X') { K[k][0]=i; K[k][1]=j; k++; } } for(int i=0;i<4;i++) { cin>>s[i]; } k=0; for(int i=1;i<5;i++) { ss[k]=s[K[0][0]-1][K[0][1]-1]; k++; ss[k]=s[K[1][0]-1][K[1][1]-1]; k++; ss[k]=s[K[2][0]-1][K[2][1]-1]; k++; ss[k]=s[K[3][0]-1][K[3][1]-1]; k++; for(int j=0;j<4;j++) { int t=K[j][0]; K[j][0]=K[j][1]; K[j][1]=5-t; } Tar(K); } ss[16]='\0'; cout<<ss; return 0; } void Tar(int K[][2]) { for(int i=0;i<4;i++) { for(int j=i+1;j<4;j++) { if(K[j][0]<K[i][0]) { int k=K[i][0],t=K[i][1]; K[i][0]=K[j][0]; K[i][1]=K[j][1]; K[j][0]=k;K[j][1]=t; } } } for(int i=1;i<4;i++) { if(K[i][0]==K[i-1][0]&&K[i][1]<K[i-1][1]) { int t=K[i][1]; K[i][1]=K[i-1][1]; K[i-1][1]=t; } } } 1.find out the equtaion, to get next location of new character after rotation each time. 2.sort the locations on basis of height. 3. print the characters on those locations. All the best. Regards Anupam Edited by author 06.11.2011 04:53 my solution #include<string> #include<iostream> using namespace std; int main() {char a[4][4],c[4][4]; int b[4][4],i,j,t; for(i=1;i<=4;i++) for(j=1;j<=4;j++) cin>>c[i][j]; for(i=1;i<=4;i++) for(j=1;j<=4;j++) cin>>a[i][j]; cout<<endl; //1 qator for(i=1;i<=4;i++) for(j=1;j<=4;j++) if(c[i][j]=='X') cout<<a[i][j]; //2-qator for(i=1;i<=4;i++) for(j=1;j<=4;j++) if(c[i][j]=='X') c[j][5-i]='1';
for(i=1;i<=4;i++) for(j=1;j<=4;j++) if(c[i][j]=='1') cout<<a[i][j]; //3-qator for(i=1;i<=4;i++) for(j=1;j<=4;j++) if(c[i][j]=='1') c[j][5-i]='2'; for(i=1;i<=4;i++) for(j=1;j<=4;j++) if(c[i][j]=='2') cout<<a[i][j]; for(i=1;i<=4;i++) for(j=1;j<=4;j++) if(c[i][j]=='2') c[j][5-i]='3'; for(i=1;i<=4;i++) for(j=1;j<=4;j++) if(c[i][j]=='3') cout<<a[i][j]; } in 1712 i have made this: [code deleted] why is a wrong answer???? Edited by moderator 19.11.2019 22:45 c[i2,j1]='x' May be big x - X I AM SO SCARED OF THIS PROBLEM, AAAAAH my e-mail is griszka90@wp.pl why WA in test 7 ???? please make your array bigger! ofcourse i've tried it on my computer it runs that program just fine i've tried submitting my solution 3 times. why is it giving me CE and WA can anyone explain it? |
|