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 1389. Roadworks

WA#2, HELP!!!!
Posted by ZiV 17 Dec 2005 00:41
Please help me, what is wrong with my solution....
Const
 MaxN = 100000;
Var
 b : array[1..MaxN] of boolean;
 c : array[1..2,1..MaxN] of longint;
 c_num,n,m,i,x,y : longint;
BEGIN
 Readln(n,m);
 Fillchar(b,sizeof(b),true);
 Fillchar(c,sizeof(c),0);
 c_num := 0;
 For i := 1 to m do
  begin
   Read(x,y);
   if b[x] and b[y] then
    Begin
     Inc(c_num);
     c[1][c_num] := x;
     c[2][c_num] := y;
     b[x] := false;
     b[y] := false;
    End;
  End;
 Writeln(c_num);
 For i := 1 to C_num do
  Begin
   Writeln(c[1][i],' ',c[2][i]);
  End;
END.
Re: WA#2, HELP!!!!
Posted by Borisov Nikita 17 Dec 2005 01:01
Try such test... :)
4 3
2 3
1 2
3 4
Correct answer is
2
1 2
3 4

I don't think, that greedy is a good idea...
Re: WA#2, HELP!!!!
Posted by gidelfino 9 Oct 2015 08:35
Try this one
4 3
1 2
1 3
3 4

Correct Answer:
2
1 2
3 4