Show all threads Hide all threads Show all messages Hide all messages | WA#3!!!!!! | Nastya | 1656. Far Away Kingdom's Army | 18 Jul 2018 07:17 | 3 | Help me please with the test number 3 try this test case: 5 170 170 180 175 170 175 175 170 175 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 170 1 1 1 170 175 170 1 1 175 180 175 170 1 1 175 1 1 1 1 1 1 1 | easy bfs) | Сонечка | 1656. Far Away Kingdom's Army | 16 Apr 2018 07:59 | 1 | | Hint on Java | the-little-worker | 1656. Far Away Kingdom's Army | 22 Jul 2013 18:03 | 1 | import java.util.*; import java.io.*; public class p1656 { public static int reverse(int k, int N) { return N - k - 1; } public static point fun(int i, int j, int N, int function) { point p = new point(); if (function == 1) { if (i != j) { p.i = reverse(j, N); p.j = reverse(i, N); } else { p.i = reverse(i, N); p.j = j; } } else if (function == 2) { if (i != j) { p.i = j; p.j = i; } else { p.i = i; p.j = reverse(j, N); } } else if (function == 3) { if (i != j) { p.i = reverse(i, N); p.j = reverse(j, N); } else { p.i = reverse(i, N); p.j = reverse(j, N); } } return p; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int N = in.nextInt(); int arr[] = new int[N * N]; //{198, 186, 181, 190, 194, 194, 174, 188, 171, 198, 182, 171, 175, 184, 177, 200, 189, 185, 177, 171, 172, 180, 186, 188, 197}; int[] out = new int[N * N]; for (int i = 0; i < N * N; i++) { arr[i] = in.nextInt(); } Arrays.sort(arr); /*for (int i = 0; i < N * N; i++) System.out.print(arr[i] + " "); System.out.println()*/; int po = 0; for (int j = 0; j < N / 2 ; j++) { for (int i = j; i < N / 2 + 1; i++) { // System.out.println("i = " + i + " j = " + j + " po = " + po); out[N * i + j] = arr[po++]; point p = fun(i, j, N, 1); //System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; p = fun(i, j, N, 2); //System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; p = fun(i, j, N, 3); //System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; if (i != j && i != N / 2 ) { int savei = i; i = reverse(i, N);
// System.out.println("i = " + i + " j = " + j + " po = " + po); out[N * i + j] = arr[po++]; p = fun(i, j, N, 1); //System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; p = fun(i, j, N, 2); // System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; p = fun(i, j, N, 3); // System.out.println("i = " + p.i + " j = " + p.j + " po = " + po); out[N * p.i + p.j] = arr[po++]; i = savei; }
} } out[N / 2 * N + N / 2] = arr[po++]; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) System.out.format("%4d", out[i * N + j]); System.out.println(); } } } class point { int i, j; } | WHY QS Do not work??? | BaJIuK | 1656. Far Away Kingdom's Army | 18 Jan 2012 18:36 | 1 | | what is the algorithm :? | 59838AD | 1656. Far Away Kingdom's Army | 10 Dec 2011 04:47 | 6 | the algorithm consist of transposition the most high soldier to the centre of the line and to the centre of the column. in cycle from 1 to n gives bubble sorting. Please can you explain how to do bubble sort in 2-d array here? I constructed such an algorithm. It requires the soldiers to be sorted by their height downwards. When the soldiers are sorted, take them one by one and fill the square diamond by diamond, starting from center. A "diamond" contains those cells (x,y) for which |x - x_center| + |y - y_center| == C, C ranges [0; n-1]. Edited by author 11.03.2009 08:54 There is a much simpler method, which also uses less memory. Hint: try a O(n) sort. Also try not to store n*n elements in memory (print line by line instead). | Help me, please why WA#3 | Harry | 1656. Far Away Kingdom's Army | 28 Sep 2011 01:25 | 1 | Here is my code: #include<iostream> #include<algorithm> using namespace std; int main(){ int n,i,a[90],ans[12][12]={0},z,x,y,j; cin>>n; for(i=0; i<n*n; i++)cin>>a[i]; sort(a,a+n*n); z=n*n-1; x=n/2+1; y=x; ans[x][y]=a[z--]; int p=1; while(z>0){ ans[x-p][y]=a[z--]; ans[x+p][y]=a[z--]; ans[x][y-p]=a[z--]; ans[x][y+p]=a[z--]; for(i=y-p; i<=y+p; i++)if(ans[x-p][i]==0)ans[x-p][i]=a[z--]; for(i=y-p; i<=y+p; i++)if(ans[x+p][i]==0)ans[x+p][i]=a[z--]; for(i=x-p; i<=x+p; i++)if(ans[i][y-p]==0)ans[i][y-p]=a[z--]; for(i=x-p; i<=x+p; i++)if(ans[i][y+p]==0)ans[i][y+p]=a[z--]; p++; } for(i=1; i<=n; i++){for(j=1; j<=n; j++)cout<<ans[i][j]<<" "; cout<<endl;} return 0;} | WA #1 | ucs6 | 1656. Far Away Kingdom's Army | 17 Sep 2011 05:08 | 1 | WA #1 ucs6 17 Sep 2011 05:08 Isn't test 1 the same as sample input? What is test #1 anyway? | W: compilation error!!! | Quyon | 1656. Far Away Kingdom's Army | 20 Nov 2010 01:24 | 4 | My program # include <iostream> using namespace std; void Paryad(int x,int y,int a[100]); void Tart(int x,int y,int a[100],int b[100]); int main () { int n=0; cin>>n; int a[100],b[100],d[100]; for (int i=1;i<=n*n;i++) cin>>a[i]; Paryad(1,n*n,a); Tart(1,n*n,a,b); int k=1,y=3; while(k<=n*n) { Paryad(k,y+k-1,b); Tart(k,y+k-1,b,d); k=k+3; } int t=0,c[100][100]; for (i=1;i<=n;i++) for(int j=1;j<=n;j++) { t=t+1; c[j][i]=d[t]; }
for (i=1;i<=n;i++) { for(int j=1;j<=n;j++) cout<<c[i][j]<<' '; cout<<endl; } return 0; } void Paryad(int x,int y,int a[100]) { int y1=0; for (int i=x;i<=y; i++) { for (int j=i+1; j<=y; j++) { if (a[i]>a[j]) { y1=a[i]; a[i]=a[j]; a[j]=y1; } } } } void Tart(int x,int y,int a[100],int b[100]) { int j=x-1,u=1; for(int i=x;i<=y;i++) { if(u==1) { j=j+1; b[j]=a[i]; u=0; } else { b[y-j+x]=a[i]; u=1; } } } first,define your varible before "for" just like "for(i=0;i<n;i++)" and don't use "for(int i=0;i<n;i++)" second,actually i don't know your"using namespace std"means, but it says it has some syntax error and var"endl" is undefined don'r post the stupid things you forgot to undeclarate identifier i in two for(...) int 22 and 29 lines of your program (must be for (int i = 0; ...), but you wrote for(i = 0;...)) But, your program gets WA3 after this. Edited by author 20.11.2010 01:24 Edited by author 20.11.2010 01:24 | Test №5 | DM^Dude | 1656. Far Away Kingdom's Army | 8 Aug 2009 01:28 | 2 | Who take "Wrong Answer" on test 5 ??? What do you do with this problem? | I create Dimond as is :) without any sort method | Oleg Strekalovsky [Vologda SPU] | 1656. Far Away Kingdom's Army | 25 Apr 2009 12:44 | 1 | | Got AC =) | MOPDOBOPOT | 1656. Far Away Kingdom's Army | 24 Apr 2009 18:22 | 1 | 0.015 sec - time 122 kb - memory To solve it, i use -=> bubble sort x2 <=- Good luck! P.S. It's my first Accepted in two last weeks, i'm feel so good now! xD | Please, repair description! | Adler3D | 1656. Far Away Kingdom's Army | 3 Mar 2009 10:37 | 3 | Please, repair problem description(russian)! Admins, hello! Please, repair description, а то половина на русском, половина на английском. | the tallest | Viktor | 1656. Far Away Kingdom's Army | 24 Dec 2008 15:33 | 6 | is there only one TALLES soldier or there can me more of them The answer 170 170 170 is alse right to the example. right? 175 180 175 170 175 175 170 175 170 170 180 175 170 175 175 Is this standing wrong? Tell please! I think there are no errors here but the example in the task is another. | WHY WA#1!! this answer is right? | Bobur | 1656. Far Away Kingdom's Army | 13 Nov 2008 23:46 | 2 | this answer is right for input example? 170 170 170 175 180 170 175 175 175 thx! * Maxim Dvoynishnikov (Dnipropetrovsk SU) 13 Nov 2008 23:46 No. Look at third column. |
|
|