This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <chrono>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <assert.h>
#define maxn 75
#define maxlog 20
#define INF 1000000010
#define mod 998244353
#define LINF 1000000000000000005
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;
#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")
using namespace std;
pair <int , int> r[10];
char c[15][15];
int n , m;
int br;
void read()
{
cin >> n >> m >> br;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
{
cin >> c[i][j];
if(c[i][j] >= '1' && c[i][j] <= '9')
r[c[i][j] - '1'] = {i , j};
}
if(r[1].X != r[2].X && r[1].Y != r[2].Y)
{
cout << -1 << endl;
assert(false);
return;
}
if(r[1].X == r[2].X)
{
cout << abs(r[1].Y - r[2].Y) << endl;
return;
}
if(r[1].Y == r[2].Y)
{
cout << abs(r[1].X - r[2].X) << endl;
return;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
read();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |