python to java converter software

Solutions on MaxInterview for python to java converter software by the best coders in the world

showing results for - "python to java converter software"
Elisa
17 Apr 2017
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}
similar questions
queries leading to this page
python to java converter software