// 2024 IUSB Programming Competition // Round 1 Problem 3 // Grid Count // Solution by Liguo Yu #include using namespace std; int main() { int m, n; cin >> m >> n; int **array = new int*[m]; for (int i = 0; i < m; i++) { array[i] = new int[n]; for (int j = 0; j < n; j++) { cin >> array[i][j]; } } bool *result = new bool[n]; for (int j = 0; j < n; j++) { result[j] = true; } for (int i = 1; i < m; i++) { for (int j = 0; j < n; j++) { if (array[i][j] < array[i - 1][j]) result[j] = false; } } int count = 0; for (int j = 0; j < n; j++) { if (result[j] == true) count++; } cout << count << endl; return 0; }