Software Development

Discover the unique matrix from the given AND matrix


  

#embrace <bits/stdc++.h>

utilizing namespace std;

  

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

    int n = arr.dimension();

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

  

    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> > outcome(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 << outcome[i][j] << " ";

            

            cout << endl;

        

    

  

int fundamental()

  

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

  

    remedy(v);

  

    return 0;

What's your reaction?

Leave A Reply

Your email address will not be published. Required fields are marked *