Thursday, November 3, 2022
HomeWordPress DevelopmentDiscover the unique matrix from the given AND matrix

Discover the unique matrix from the given AND matrix


  

#embody <bits/stdc++.h>

utilizing namespace std;

  

void resolve(vector<vector<bool> >& arr)

{

    int n = arr.measurement();

    int m = arr[0].measurement();

  

    set<int> row;

    set<int> col;

  

    vector<vector<bool> > unique(arr);

  

    

    

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

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

            if (arr[i][j]) {

                row.insert(i);

                col.insert(j);

            }

        }

    }

  

    

    for (auto it : row) {

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

            arr[it][i] = 1;

        }

    }

  

    

    for (auto it : col) {

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

            arr[i][it] = 1;

        }

    }

  

    vector<vector<bool> > consequence(arr);

  

    row.clear();

    col.clear();

  

    

    

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

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

            if (!arr[i][j]) {

                row.insert(i);

                col.insert(j);

            }

        }

    }

  

    

    for (auto it : row) {

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

            arr[it][i] = 0;

        }

    }

  

    

    for (auto it : col) {

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

            arr[i][it] = 0;

        }

    }

  

    

    

    if (arr != unique) {

        cout << -1 << endl;

    }

  

    

    else {

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

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

                cout << consequence[i][j] << " ";

            }

            cout << endl;

        }

    }

}

  

int predominant()

{

  

    vector<vector<bool> > v = { { 1, 0, 1 }, { 0, 0, 0 } };

  

    resolve(v);

  

    return 0;

}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments