ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1604. Country of Fools

WA#4, help!!!!!!!!!! here is my code
Posted by Bobur 2 Mar 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
Posted by VoffKa_OSU 2 Mar 2008 21:34
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
Posted by panrui 16 Mar 2008 09:48
And this:
3
1 2 5
Answer:
3 1 3 2 3 2 3 3
thx
Posted by Bobur 19 Mar 2008 18:26
thanks a lot!
Re: WA#4, help!!!!!!!!!! here is my code
Posted by Elmurod 30 Oct 2008 11:38
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
Posted by D_PRO 8 Sep 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
////
Posted by SuperLight 8 Sep 2009 14:36
Re: ////
Posted by bsu.mmf.team 28 Apr 2010 14:32
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
Posted by MOPDOBOPOT (USU) 9 Feb 2011 23:50
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
Posted by MOPDOBOPOT (USU) 10 Feb 2011 00:03
AC now :)

Edited by author 28.05.2011 17:05