-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUva10102.cpp
More file actions
56 lines (51 loc) · 1.25 KB
/
Copy pathUva10102.cpp
File metadata and controls
56 lines (51 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <set>
#include <string.h>
using namespace std;
typedef vector<int> vi;
int main()
{
int N;
while(cin>>N){
vector<vi> coll;
string str;
for(int i=0;i<N;i++){
cin>>str;
vi temp;
for(int j=0;j<str.size();j++){
int dig=str[j] - '0';
temp.push_back(dig);
}
coll.push_back(temp);
}
int Max=0;
vector<int> dists;
for(int i=0;i<coll.size();i++){
for(int j=0;j<coll.size();j++){
if(coll[i][j]==1){
int mn=INFINITY;
for(int k=0;k<coll.size();k++){
for(int l=0;l<coll.size();l++){
if(coll[k][l]==3){
int tmp=abs(k-i) + abs(l-j);
mn=min(mn,tmp);
}
}
}
Max=max(Max,mn);
}
}
}
cout<<Max<<endl;
}
return 0;
}