function [rows cols count] = cover( distance,slength )
rows=zeros(slength,1);
cols=zeros(slength,1);
oldrows=rows;
oldcols=cols;
assign=zeros(slength,2);
count=1;



%for uuc=1:slength
%    if length(find(distance(uuc,:)==0))==1
%        rows(uuc,1)=1;
%    end
%end

%for uuc=1:slength
%    if length(find(distance(:,uuc)==0))==1
%        for yukari=1:slength
%            if distance(yukari,uuc)==0
%                rows(yukari,1)=1;
%            end
%        end
%    end
%end


for uuc=1:slength
    for yukari=1:slength
        if distance(yukari,uuc)==0 && rows(yukari,1)==0
            rows(yukari,1)=1;
            assign(count,1)=yukari;
            assign(count,2)=uuc;
            count=count+1;
            break;
        end
    end
end




while ~isequal(oldrows,rows) || ~isequal(oldcols,cols)
oldrows=rows;
oldcols=cols; 
for uuc=1:slength
    if rows(uuc,1)==0
        for yukari=1:slength
            if distance(uuc,yukari)==0
                cols(yukari,1)=1;
            end
        end
    end
end

for uuc=1:slength
    if cols(uuc,1)==1
        for yukari=1:slength
            if assign(yukari,2)==uuc
                rows(assign(yukari,1),1)=0;
            end
        end
    end
end

end  

count=0;
for uuc=1:slength
    if rows(uuc,1)==1
        count=count+1;
    end
end

for uuc=1:slength
    if cols(uuc,1)==1
        count=count+1;
    end
end


end

