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 1208. Legendary Teams Contest

Why I got WA????
Posted by DDNEW 12 Jan 2003 13:07
var a:array[1..54]of string[20];
    team:array[1..18,1..3]of integer;
    t:array[1..54]of boolean;
    max,n,i,j,k,kk:integer;
    ch:char;
    st,st1:string;

 procedure dfs(s,k:integer);
 var i:integer;

  function Ok:boolean;
  var j:integer;

  begin
       for j:=1 to 3 do
         if t[team[i,j]] then
           begin
                ok:=false;
                exit;
           end;
       Ok:=true;
  end;

 begin
      for i:=k+1 to n do
          if ok then
            begin
                 t[team[i,1]]:=true;
                 t[team[i,2]]:=true;
                 t[team[i,3]]:=true;
                 dfs(s+1,i);
                 if s>max then max:=s;
                 t[team[i,1]]:=false;
                 t[team[i,2]]:=false;
                 t[team[i,3]]:=false;
            end;
 end;

begin
     close(input);
     assign(input,'a.in');
     reset(input);
     for i:=1 to 54 do a[i]:='';
     readln(n);
     kk:=0;
     for i:=1 to n do
       begin
            readln(st);
            st:=st+' ';
            j:=1;
            while j<=3 do
              begin
                   while (j<=3)and(st[1]<>' ')do
                     begin
                          st1:=st1+st[1];
                          delete(st,1,1);
                     end;
                   delete(st,1,1);
                   for k:=1 to kk+1 do
                     if st1=a[k] then break;
                   team[i,j]:=k;
                   if k=kk+1 then begin a[k]:=st1;inc(kk);end;
                   st1:='';
                   inc(j);
              end;
       end;
     max:=0;
     fillchar(t,sizeof(t),false);
     dfs(1,0);
     writeln(max);
end.
I'm sorry! Here is my program
Posted by DDNEW 12 Jan 2003 13:09
> var a:array[1..54]of string[20];
>     team:array[1..18,1..3]of integer;
>     t:array[1..54]of boolean;
>     max,n,i,j,k,kk:integer;
>     ch:char;
>     st,st1:string;
>
>  procedure dfs(s,k:integer);
>  var i:integer;
>
>   function Ok:boolean;
>   var j:integer;
>
>   begin
>        for j:=1 to 3 do
>          if t[team[i,j]] then
>            begin
>                 ok:=false;
>                 exit;
>            end;
>        Ok:=true;
>   end;
>
>  begin
>       for i:=k+1 to n do
>           if ok then
>             begin
>                  t[team[i,1]]:=true;
>                  t[team[i,2]]:=true;
>                  t[team[i,3]]:=true;
>                  dfs(s+1,i);
>                  if s>max then max:=s;
>                  t[team[i,1]]:=false;
>                  t[team[i,2]]:=false;
>                  t[team[i,3]]:=false;
>             end;
>  end;
>
> begin
>      for i:=1 to 54 do a[i]:='';
>      readln(n);
>      kk:=0;
>      for i:=1 to n do
>        begin
>             readln(st);
>             st:=st+' ';
>             j:=1;
>             while j<=3 do
>               begin
>                    while (j<=3)and(st[1]<>' ')do
>                      begin
>                           st1:=st1+st[1];
>                           delete(st,1,1);
>                      end;
>                    delete(st,1,1);
>                    for k:=1 to kk+1 do
>                      if st1=a[k] then break;
>                    team[i,j]:=k;
>                    if k=kk+1 then begin a[k]:=st1;inc(kk);end;
>                    st1:='';
>                    inc(j);
>               end;
>        end;
>      max:=0;
>      fillchar(t,sizeof(t),false);
>      dfs(1,0);
>      writeln(max);
> end.