#include <stdio.h>
#include <vector>
int p[2010][2010], pos[2010], res;
int main() {
int n, m;
scanf("%d %d", &n, &m);
for(int i=0; i<n; i++) {
for(int j=0; j<m; j++) {
scanf("%d", &p[i][j]);
}
}
for(int j=0; j<m; j++) {
int max=-1;
std::vector<int> v;
for(int i=0; i<n; i++) {
if(max<p[i][j]) {
v.clear();
max=p[i][j];
}
if(max==p[i][j]) {
v.push_back(i);
}
}
if(v.size()==1) pos[v[0]]=1;
}
for(int i=0; i<n; i++) res+=pos[i];
printf("%d", res);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: