Sunday, June 29, 2014

Codeforces Round #161 (Div. 2), problem: (A) Beautiful Matrix solution

Codeforces Round #161 (Div. 2), problem: (A) Beautiful Matrix: http://codeforces.com/problemset/problem/263/A

Codeforces Round #161 (Div. 2), problem: (A) Beautiful Matrix editorial: http://codeforces.com/blog/entry/6419

Codeforces Round #161 (Div. 2), problem: (A) Beautiful Matrix solution: http://ideone.com/akttbJ


#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
    int a[6][6], ans, idx, idy;
    for(int i=0; i<5; i++) for(int j=0; j<5; j++) {scanf("%d", &a[i][j]); if(a[i][j]) idx=i, idy=j;}
    ans=abs(idx-2)+abs(idy-2);
    printf("%d", ans);
    return 0;
}

No comments:

Post a Comment