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 1506. Columns of Numbers

Why WA2? I think I my prog is correct... Who can help me?
Posted by Yashar Abbasov 26 Oct 2007 02:33
My prog gives WA#2... Do I have any bug in my prog?

Here's my code:

var
 k,i,j,nc,n:integer;
 mas,ar:array [1..100] of integer;

function bool(x:integer):boolean;
var
 l:integer;
begin
 l:=0; bool:=false;
 for l:=1 to j do
  if mas[l]=x then
   begin
    bool:=true; break;
   end;
end;

begin
 readln(n,k);
 for i:=1 to n do read(ar[i]);
 if n mod 2=0 then nc:=round(n/k)
              else nc:=round(n/k+1);
 i:=1; j:=0;
 while true do
  begin
   if (not bool(i))and(i<=n) then
    begin
     inc(j); mas[j]:=i;
     write(ar[i]:4);
     if j>=n then exit;
     inc(i,nc);
    end                      else
   if i>n then begin writeln; i:=1; end
          else
   if bool(i) then inc(i);
  end;
end.


Edited by author 26.10.2007 02:33
Re: Why WA2? I think I my prog is correct... Who can help me?
Posted by Chidori-kun 31 Oct 2007 02:27
Input:
5 3
1 2 30 40 50 600 700

Output(Your):
   1  40
   2  50
  30

Output(Right):
   1  30  50
   2  40

GL!
Re: Why WA2? I think I my prog is correct... Who can help me?
Posted by Yashar Abbasov 9 Nov 2007 00:52
Yes, thanks i understood my mistake. Sorry but i don't have any idea according to correcting it?
Can you help me,please?