function F = Scorer(S,O,d)
[n dump] = size(S);
Cold = zeros(n,1);
C = zeros(n,1);
for i = 1:n
    if S(i) == 1
        C(i) = d(i);
    end
end
while min(C == Cold) == 0
    Cold = C;
    for j = 1:n
        for i = 1:n
            if O(i,j) == 1 && Cold(i)+d(j) > Cold(j)
                C(j) = Cold(i)+d(j);
            end
        end
    end
end
F = max(C);
end