#include<stdio.h> #include<math.h> int main() { int h,l,a[25][25],i,j; for(i=1;i<=5;i++) for(j=1;j<=5;j++) { scanf("%d",&a[i][j]); if(a[i][j]==1)h=i,l=j; } printf("%d",abs(3-h)+abs(3-l)); return 0; }
http://codeforces.com/contest/263/problem/A