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 1025. Democracy in Danger

help, why it got wa?
Posted by BShell 4 Jan 2003 17:24
var g:array[1..100,1..100] of boolean;
    d:array[1..100] of integer;
    v:array[1..100] of boolean;
    i,j,x,n,sum:integer;
begin
  readln(n);
  fillchar(g,sizeof(g),false);
  fillchar(d,sizeof(d),0);
  for i:=1 to n do
  begin
    repeat
      read(x);
      if x=0 then break;
      g[i,x]:=true;
      inc(d[x]);
    until false;
  end;
  sum:=0;
  fillchar(v,sizeof(v),false);
  repeat
    for i:=1 to n do
    if (not v[i]) and (d[i]=0) then
    begin
      v[i]:=true;
      inc(sum);
      for j:=1 to n do
      if g[i,j] then dec(d[j]);
      if sum<n then write(i,' ')
      else writeln(i);
    end;
  until sum=n;
end.
Re: help, why it got wa?
Posted by Илья Гофман (Ilya Gofman) 6 Jan 2003 19:52
What the hell are you doing here? You only need to sort the array
and then output half of it.
I'm doing that exactly but WA on test #5, why???
Posted by Maigo Akisame 17 Jun 2004 16:03
program ural1025;
const
  maxk=101;
var
  p:array[1..maxk]of integer;
  k,i,j:byte;
  t:integer;
begin
  readln(k);
  for i:=1 to k do
    read(p[i]);

  for i:=1 to k-1 do
    for j:=i+1 to k do
      if p[i]>p[j] then begin
        t:=p[i];p[i]:=p[j];p[j]:=t;
      end;

  k:=k div 2+1;t:=0;
  for i:=1 to k do
    inc(t,p[k] div 2+1);

  writeln(t);
end.
Silly mistake, repaired.
Posted by Maigo Akisame 19 Jun 2004 04:31