924A - Mystical Mosaic - CodeForces Solution


greedy implementation *1300

Please click on ads to support us..

C++ Code:

#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    int n, m;
    cin >> n >> m;

    vector<vector<bool>> a(n, vector<bool>(m, false));

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            char v;
            cin >> v;

            a[i][j] = v == '#';
        }

    for (int i = 0; i < n - 1; i++)
        for (int j = i + 1; j < n; j++)
        {
            bool noIntersection = true;
            bool equal = true;
            for (int k = 0; k < m; k++)
            {
                if (a[i][k] != a[j][k])
                    equal = false;
                if (a[i][k] && a[j][k])
                    noIntersection = false;
            }
            if (!equal && !noIntersection)
            {
                cout << "No\n";
                return 0;
            }
        }

    cout << "Yes\n";

    return 0;
}


Comments

Submit
0 Comments
More Questions

1706C - Qpwoeirut And The City
1697A - Parkway Walk
1505B - DMCA
478B - Random Teams
1705C - Mark and His Unfinished Essay
1401C - Mere Array
1613B - Absent Remainder
1536B - Prinzessin der Verurteilung
1699B - Almost Ternary Matrix
1545A - AquaMoon and Strange Sort
538B - Quasi Binary
424A - Squats
1703A - YES or YES
494A - Treasure
48B - Land Lot
835A - Key races
1622C - Set or Decrease
1682A - Palindromic Indices
903C - Boxes Packing
887A - Div 64
755B - PolandBall and Game
808B - Average Sleep Time
1515E - Phoenix and Computers
1552B - Running for Gold
994A - Fingerprints
1221C - Perfect Team
1709C - Recover an RBS
378A - Playing with Dice
248B - Chilly Willy
1709B - Also Try Minecraft