結果
問題 |
No.2911 位相の公理
|
ユーザー |
|
提出日時 | 2024-10-04 22:32:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,195 ms / 2,000 ms |
コード長 | 878 bytes |
コンパイル時間 | 1,871 ms |
コンパイル使用メモリ | 204,484 KB |
最終ジャッジ日時 | 2025-02-24 15:28:47 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (int)(n); i++) void solve() { ll n, m; cin >> n >> m; vector<ll> a(m); vector<bool> used(1 << n, false); rep(i, m) { string s; cin >> s; ll b = 1; rep(j, n) { if (s[j] == '1') a[i] += b; b <<= 1; } used[a[i]] = true; } bool ok = used[0] && used[(1 << n) - 1]; rep(j, m) rep(i, j) ok &= used[a[i] & a[j]]; set<ll> now; now.insert(0); rep(i, m) if (ok && a[i] > 0) { for (auto iter = now.rbegin(); iter != now.rend(); iter++) { ll x = *iter | a[i]; ok &= used[x]; now.insert(x); } } cout << (ok ? "Yes" : "No") << '\n'; } int main() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); int T = 1; for (int t = 0; t < T; t++) { solve(); } return 0; }