1#include <bits/stdc++.h>
2using namespace std;
3
4int main()
5{
6 int m,ans=INT_MAX,I=-1,J=-1;
7 cin>>m;
8 vector<vector<int>> mat(m,vector<int>());
9 cin.ignore();
10 for(int i=0;i<m;i++)
11 {
12 string s;
13 getline(cin,s);
14 istringstream ss(s);
15 while(ss)
16 {
17 string w;
18 ss>>w;
19 if(w=="") break;
20 mat[i].push_back(stoi(w));
21 }
22 }
23 int n=mat[0].size();
24 vector<vector<int>> Ans1(m,vector<int>(n,1));
25 vector<vector<int>> Ans2(m,vector<int>(n,1));
26 vector<vector<int>> Ans3(m,vector<int>(n,1));
27 vector<vector<int>> Ans4(m,vector<int>(n,1));
28
29 for(int i=0;i<m-1;i++)
30 for(int j=0;j<mat[i].size();j++)
31 if(mat[i][j]==mat[i+1][j])
32 Ans1[i+1][j]=Ans1[i][j]+1;
33
34 for(int i=0;i<m;i++)
35 for(int j=0;j<mat[i].size() -1;j++)
36 if(mat[i][j]==mat[i][j+1])
37 Ans2[i][j+1]=Ans2[i][j]+1;
38
39 for(int i=0;i<m-1;i++)
40 for(int j=0;j<mat[i].size()-1;j++)
41 if(mat[i][j]==mat[i+1][j+1])
42 Ans3[i+1][j+1]=Ans3[i][j]+1;
43
44 for(int i=0;i<m-1;i++)
45 for(int j=1;j<mat[i].size();j++)
46 if(mat[i][j]==mat[i+1][j-1])
47 Ans4[i+1][j-1]=Ans4[i][j]+1;
48
49 for(int i=0;i<m;i++)
50 for(int j=0;j<mat[i].size();j++)
51 {
52 if(Ans1[i][j]>=4 && ans>mat[i][j])
53 {ans=mat[i][j];I=i;J=j;}
54 if(Ans2[i][j]>=4 && ans>mat[i][j])
55 {ans=mat[i][j];I=i;J=j;}
56 if(Ans3[i][j]>=4 && ans>mat[i][j])
57 {ans=mat[i][j];I=i;J=j;}
58 if(Ans3[i][j]>=4 && ans>mat[i][j])
59 {ans=mat[i][j];I=i;J=j;}
60 }
61 if(I==-1)cout<<-1;
62 else cout<<ans<<endl;
63
64}
1def tipo_melenudos(lista):
2 lista_nueva=[]
3 for i in range(len(lista)):
4 if lista[i] not in lista_nueva:
5 lista_nueva.append(lista[i])
6 return lista_nueva
1def BitmapHoles(strArr):
2 bitmap = {}
3 for i in range(len(strArr)):
4 for j in range(len(strArr[i])):
5 bitmap[(i,j)] = int(strArr[i][j])
6
7 hole_count = 0
8 hole = set()
9 checked = set()
10 flag = True
11
12 for i in range(len(strArr)):
13 for j in range(len(strArr[i])):
14 stack = [(i,j)]
15 while stack:
16 coords = stack.pop()
17 if coords not in checked:
18 checked.add(coords)
19 if bitmap[coords] == 0 and coords not in hole:
20 hole.add(coords)
21 if flag == True:
22 hole_count += 1
23 flag = False
24 if coords[0] - 1 >= 0 and (coords[0]-1,coords[1]) not in checked:
25 stack.append((coords[0]-1,coords[1]))
26 if coords[0] + 1 < len(strArr) and (coords[0]+1,coords[1]) not in checked:
27 stack.append((coords[0]+1,coords[1]))
28 if coords[1] - 1 >= 0 and (coords[0],coords[1]-1) not in checked:
29 stack.append((coords[0],coords[1]-1))
30 if coords[1] + 1 < len(strArr[coords[0]]) and (coords[0],coords[1]+1) not in checked:
31 stack.append((coords[0],coords[1]+1))
32 flag = True
33
34 return hole_count
35
1n = int(input())
2output = []
3strings = []
4for _ in range(n):
5 strings.append(input().strip())
6q = int(input())
7for _ in range(q):
8 L,R,K = map(int, input().split())
9 s = ""
10 for __ in range(L-1,R):
11 s += strings[__]
12 output.append(s[K-1])
13print(*sorted(output),sep='\n')
1def BitmapHoles(strArr):
2 bitmap = {}
3 for i in range(len(strArr)):
4 for j in range(len(strArr[i])):
5 bitmap[(i,j)] = int(strArr[i][j])
6
7 hole_count = 0
8 hole = set()
9 checked = set()
10 flag = True
11
12 for i in range(len(strArr)):
13 for j in range(len(strArr[i])):
14 stack = [(i,j)]
15 while stack:
16 coords = stack.pop()
17 if coords not in checked:
18 checked.add(coords)
19 if bitmap[coords] == 0 and coords not in hole:
20 hole.add(coords)
21 if flag == True:
22 hole_count += 1
23 flag = False
24 if coords[0] - 1 >= 0 and (coords[0]-1,coords[1]) not in checked:
25 stack.append((coords[0]-1,coords[1]))
26 if coords[0] + 1 < len(strArr) and (coords[0]+1,coords[1]) not in checked:
27 stack.append((coords[0]+1,coords[1]))
28 if coords[1] - 1 >= 0 and (coords[0],coords[1]-1) not in checked:
29 stack.append((coords[0],coords[1]-1))
30 if coords[1] + 1 < len(strArr[coords[0]]) and (coords[0],coords[1]+1) not in checked:
31 stack.append((coords[0],coords[1]+1))
32 flag = True
33
34 return hole_count
1def tipo_melenudos(lista):
2 lista_nueva=[]
3 for i in range(len(lista)):
4 if lista[i] not in lista_nueva:
5 lista_nueva.append(lista[i])
6 return lista_nueva
1s=input()
2l=[]
3s1='aeiou'
4sum1=0
5def snm(sum1):
6 t=0
7 while(sum1>0 or t>9):
8 if(sum1==0):
9 sum1=t
10 t=0
11 t=t+sum1%10
12 sum1=sum1//10
13 return t
14
15for i in range(len(s)):
16 if s[i] in s1:
17 l.append(i)
18for j in range(len(l)):
19 k=l[j]*5
20 sum1=0
21 for h in range(1,k+1,2):
22 sum1=sum1+h
23 print(snm(sum1))