Winner Nicke (Revolution IV)

Finish 2003-11-13 15:00:00 UTC

Revolution II

by Nicke

Status: Passed
Results: pass
CPU Time: 14.551
Score: 197.0
Submitted at: 2003-11-06 17:56:48 UTC
Scored at: 2003-11-06 20:14:10 UTC

Current Rank: 8th

Comments
Please login or create a profile.
Code
[m n]=size(a);
y=m*n;
P(y,y)=0;
for i=1:y
 [v w]=ind2sub(m,i);
 t=i+[v<m -(v>1) m*[w<n -(w>1)]];
 P(i,t(a(t)==a(i)+1))=1;
end
g=-1;
while any(t(:)),
 g=g+1;
 [b r]=find(t);
 t=P^g;
end
for m=g:-1:0
 w=P^m;
 b=[b; find(P(b(end),:).*w(:,r)')];
end