結果

問題 No.3311 フィルター
コンテスト
ユーザー GOTKAKO
提出日時 2025-10-24 22:03:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 673 bytes
コンパイル時間 1,740 ms
コンパイル使用メモリ 199,124 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-10-25 12:57:11
合計ジャッジ時間 2,355 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int N,M; cin >> N >> M;
    int n2 = 1<<N;
    vector<bool> need(n2),S(n2);
    vector<int> A(M);
    int And = n2-1;
    for(auto &a : A){
        string s; cin >> s;
        for(auto c : s) a *= 2,a += c-'0';
        S.at(a) = true,need.at(a) = true;
        And &= a;
    }
    for(int i=0; i<n2; i++) if(need.at(i)) for(int k=0; k<N; k++) if(!(i&(1<<k))) need.at(i+(1<<k)) = true;
    if(S.at(0) || !S.at(And)){cout << "No\n"; return 0;}
    for(int i=0; i<n2; i++) if(need.at(i) && !S.at(i)){cout << "No\n"; return 0;}

    cout << "Yes\n";
}
0