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

Bobur WA#4, help!!!!!!!!!! here is my code [9] // Problem 1604. Country of Fools 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!!!
VoffKa_OSU Re: WA#4, help!!!!!!!!!! here is my code [6] // Problem 1604. Country of Fools 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
And this:
3
1 2 5
Answer:
3 1 3 2 3 2 3 3
Bobur thx // Problem 1604. Country of Fools 19 Mar 2008 18:26
thanks a lot!
Elmurod Re: WA#4, help!!!!!!!!!! here is my code [1] // Problem 1604. Country of Fools 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
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
SuperLight //// [1] // Problem 1604. Country of Fools 8 Sep 2009 14:36
bsu.mmf.team Re: //// // Problem 1604. Country of Fools 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
MOPDOBOPOT (USU) Re: WA#4, help!!!!!!!!!! here is my code [1] // Problem 1604. Country of Fools 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
MOPDOBOPOT (USU) No subject // Problem 1604. Country of Fools 10 Feb 2011 00:03
AC now :)

Edited by author 28.05.2011 17:05