← Back to List

17247번: 택시 거리 ↗

Solutions

C++14
279 B | 279 chars
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int a,N,M;
vector <int> v;
int main()
{
    cin>>N>>M;
    for(int x=0; x<N*M; x++)
    {
        cin>>a;
        if(a==1) v.push_back(x); 
    }

    cout<< abs(v[0]/M - v[1]/M) + abs(v[0]%M -v[1]%M);
}