Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

AC^_^

Posted by JiangLY at 2005-07-24 19:55:31 on Problem 1659
In Reply To:同问,贪心为什么WA?(我的程序见内) Posted by:JiangLY at 2005-07-24 17:18:28
> var
>   map:array[1..10,1..10] of longint;
>   s:array[1..10] of longint;
>   t,ti,i,j,k,n:longint;
>   f:boolean;
> begin
>   readln(t);
>   for ti:=1 to t do
>     begin
>       readln(n);
>       for i:=1 to n do read(s[i]);
>       readln;
>       fillchar(map,sizeof(map),0);
>       for i:=1 to n do
>         if s[i]<>0 then
>           for j:=1 to n do
>             if i<>j then
>               if s[j]<>0 then
>                 if map[i,j]=0 then
>                   begin
>                     dec(s[i]);
>                     dec(s[j]);
>                     map[i,j]:=1;
>                     map[j,i]:=1;
>                     if s[i]=0 then break;
>                   end;
>       f:=true;
>       for i:=1 to n do
>         if s[i]<>0 then
>           begin
>             f:=false;
>             break;
>           end;
>       if not f then writeln('NO')
>                else
>                  begin
>                    writeln('YES');
>                    for i:=1 to n do
>                      begin
>                        for j:=1 to n do write(map[i,j],' ');
>                        writeln;
>                      end;
>                  end;
>       writeln;
>     end;
> end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator