-
Notifications
You must be signed in to change notification settings - Fork 0
/
STWK8TEST.cpp
60 lines (53 loc) · 860 Bytes
/
STWK8TEST.cpp
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
57
58
59
60
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int main() {
int n,m;
cin>>n>>m;
vector<vector<int>> v(n,vector<int>(m));
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
cin>>v[i][j];
}
vector<int> v1,v2;
for(int i=0;i<n;i++)
{
int maxi=0;
for(int j=0;j<m;j++)
{
maxi=max(maxi,v[i][j]);
}
v1.push_back(maxi);
}
for(int i=0;i<m;i++)
{
int mini=1e9;
for(int j=0;j<n;j++)
{
mini=min(mini,v[j][i]);
}
v2.push_back(mini);
}
bool found=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(v[i][j]==v1[i] and v[i][j]==v2[j])
{
found=1;
break;
}
}
if(found)
break;
}
if(found)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 0;
}