文章

1

粉丝

124

获赞

1

访问

5.4k

头像
一行/列有可能有多个鞍点
P1531 四川大学2019年/东南大学机试题
发布于2021年6月14日 19:23
阅读数 5.4k

#include <iostream>

#include <vector>

using namespace std;



const int check(int x, int y, vector<vector<int>> &mat) {

    int row=mat.size(), col=mat[0].size();

    for (int i=0; i < row; i++) {

        if (mat[i][y] < mat[x][y]) {

            return false;

        }

    }

    for (int j=0; j < col; j++) {

        if (mat[x][j] > mat[x][y]) {

            return false;

        }

    }

    return true;

}



int main () {

    int row, col;

    cin >> row >> col;

    vector<vector<int>> mat(row, vector<int>(col));

    bool flag=true;

    

    

    for (int i=0; i<row; i++) {

        for (int j=0; j<col; j++) {

            cin>>mat[i][j];

        }

    }




    for (int i=0; i<row; i++) {

        for (int j=0; j<col; j++) {

            if (check(i, j, mat)) {

                flag = false;

      ...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发