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 1124. Mosaic

WA13 Why!!!!
Posted by ZiV 31 Jan 2006 16:42
Const
 MaxN = 500;
Answer is sum of edjes in graph and subgraphs(except graphs with one vertex)...
Var
 n,m,i,j,k,x: longint;
 b,c : array[1..MaxN] of Word;
BEGIN
 Read(m,n);
 K := 0;
 Fillchar(c,sizeof(c),0);
 For i := 1 to m do
  b[i] := i;
 For i := 1 to m do
  For j := 1 to n do
   Begin
    Read(x);
    if x <> i then
     Inc(k); // I count number of edjes
    b[x] := b[i];
   End;
 For i := 1 to m do
  Begin
   Inc(c[b[i]]);
   if c[b[i]] = 2 then
    Inc(k); // Here i count number of subgraphs
  End;
 Writeln(k-1+byte((k-1)<0));
END.
Re: WA13 Why!!!!
Posted by Okey 25 Sep 2007 19:13
I am WA too....
who can give us any hits???