|
|
back to boardhelp, 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? 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??? 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. |
|
|