class Solution {public: bool searchMatrix(vector> &matrix, int target) { int low=0,high=matrix.size()-1; if(high==-1)return 0; int level=0; //if(matrix[0][0]>target)return false; while(low<=high) { level=(low+high)/2; if(matrix[level][0]==target)return true; if(matrix[level][0]>target)high=level-1; if(matrix[level][0] target) break; else low=level+1; } } low=1,high=matrix[0].size()-1; int m; while(low<=high) { m=(low+high)/2; if(matrix[level][m]==target)return true; if(matrix[level][m]>target)high=m-1; if(matrix[level][m]