fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, m,uf = 0;
  6. //input
  7. cin >> n >> m;
  8. int ** x = new int * [n];
  9. for (int i = 0; i < n; i++)
  10. x[i] = new int[m];
  11. for (int i = 0; i < n; i++)
  12. for (int j = 0; j < m; j++)
  13. cin >> x[i][j];
  14. //workspace
  15. for (int i = 0; i < n; i++) {
  16. int min = x[i][0];
  17. for (int j = 1; j < m; j++) {
  18. if ( min > x[i][j] ) {
  19. min = x[i][j];
  20. }
  21. }
  22. for (int j = 0; j < m; j++) {
  23. if (x[i][j] == min) {
  24. int max = x[i][j];
  25. for (int l = 0; l < n; l++) {
  26. if (max < x[l][j]){
  27. max = x[l][j];
  28. }
  29. }
  30. if ( max == min) {
  31. uf++;
  32. }
  33. }
  34. }
  35. }
  36. //output
  37. cout << uf;
  38. return 0;
  39. }
Success #stdin #stdout 0s 4352KB
stdin
2 2
3 2
1 1
stdout
1