|
|
вернуться в форумWA#4, help!!!!!!!!!! here is my code Послано Bobur 2 мар 2008 16:27 var a, b, c : array [1..10000] of integer; k, n, s, i, j : integer; toq : boolean; procedure quicksort; procedure sort(l, r : integer); var i1, j1, x, w : integer; begin i1 := l; j1 := r; x := a[(l+r) div 2]; repeat while a[i1]<x do inc(i1); while x<a[j1] do dec(j1); if i1 <= j1 then begin w := a[i1]; a[i1] := a[j1]; a[j1] := w; w := b[i1]; b[i1] := b[j1]; b[j1] := w; inc(i1); dec(j1); end; until i1 > j1; if l < j1 then sort(l, j1); if i1 < r then sort(i1, r); end; begin sort(1, n); end;{quicksort} begin read(n); for k := 1 to n do begin read(a[k]); b[k] := k; end; s := 0; for k := 1 to n do s := s + a[k]; quicksort; toq := true; for k := 1 to n do begin if toq then begin j := 1; i := 1; while (i <= s) and (j <= a[k]) do begin c[i] := b[k]; inc(i, 2); inc(j); end; if i > s then toq := false; end; if toq = false then begin j := 1; i := 2; while (i <= s) and (j <= a[k]) do begin c[i] := b[k]; inc(i, 2); inc(j); end; end; end; for i := 1 to s do write(c[i], ' '); end. or smth wrong with my idea!!! Re: WA#4, help!!!!!!!!!! here is my code check this test 3 5 8 10 correct answer 1 3 2 3 1 3 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 2 3 Edited by author 02.03.2008 21:38 Re: WA#4, help!!!!!!!!!! here is my code Послано panrui 16 мар 2008 09:48 And this: 3 1 2 5 Answer: 3 1 3 2 3 2 3 3 thx Послано Bobur 19 мар 2008 18:26 thanks a lot! Re: WA#4, help!!!!!!!!!! here is my code test : 3 5 8 10 answer: will be this answer correct too? 1 2 3 2 1 2 3 2 1 2 3 2 1 2 3 2 1 2 3 2 1 2 3 Edited by author 30.10.2008 11:39 Re: WA#4, help!!!!!!!!!! here is my code Послано D_PRO 8 сен 2009 12:18 and this? 3 5 8 10 answer: 3 2 3 2 3 2 3 1 3 2 3 1 2 3 1 2 3 1 2 3 1 2 3 Re: //// Test #4 is something like this: 2 5 1 answer: 1 2 1 1 1 1 Ans Test #6: 2 2 6 answer: 2 2 2 1 2 1 2 2 Edited by author 28.04.2010 14:40 Re: WA#4, help!!!!!!!!!! here is my code Test 4 is something like this: (I fixed this when had WA4 and got WA26) 3 1 1 3 ------- 3 1 3 2 3 Edited by author 09.02.2011 23:51 No subject AC now :) Edited by author 28.05.2011 17:05 |
|
|