結果

問題 No.2911 位相の公理
ユーザー Tatsu_mr
提出日時 2024-10-04 21:47:17
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 860 ms / 2,000 ms
コード長 1,073 bytes
コンパイル時間 3,217 ms
コンパイル使用メモリ 252,248 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-04 21:47:25
合計ジャッジ時間 6,526 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for(long long i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;

using lint = long long;

int main() {
    int n, m;
    cin >> n >> m;
    auto f = [&](string s) -> int {
        int res = 0;
        int cur = 1;
        rep(i, n) {
            res += cur * (s[n - i - 1] - '0');
            cur *= 2;
        }
        return res;
    };
    vector<int> a(m);
    set<int> s;
    rep(i, m) {
        string x;
        cin >> x;
        int y = f(x);
        a[i] = y;
        s.insert(y);
    }
    if (!s.count((1 << n) - 1)) {
        cout << "No" << endl;
        return 0;
    }
    rep(i, m) rep(j, m) {
        if (!s.count(a[i] & a[j])) {
            cout << "No" << endl;
            return 0;
        }
    }
    rep(bit, (1 << m)) {
        int cur = 0;
        rep(i, m) {
            if (bit & (1 << i)) {
                cur |= a[i];
            }
        }
        if (!s.count(cur)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}
0