NKONEARC - Mạng máy tính
Tác giả: RR
Ngôn ngữ: Pascal
const
FINP='';
FOUT='';
var
f1,f2:text;
vao,ra:array [1..2000] of byte;
n,m:longint;
procedure openF;
begin
assign(f1,FINP); reset(f1);
assign(f2,FOUT); rewrite(f2);
end;
procedure closeF;
begin
close(f1); close(f2);
end;
procedure inp;
var
i,x,y:longint;
begin
readln(f1,n,m);
for i:=1 to m do
begin
readln(f1,x,y);
vao[y]:=1;
ra[x]:=1;
end;
end;
procedure ans;
var
i,u,v,count:longint;
begin
count:=0;
for i:=1 to n do
begin
if vao[i]=0 then
begin
u:=i;
inc(count);
end
else if ra[i]=0 then
begin
v:=i;
inc(count);
end;
if count=2 then break;
end;
writeln(f2,'YES');
write(f2,v,' ',u);
end;
begin
openF;
inp;
ans;
closeF;
end.