結果
問題 |
No.2910 単体ホモロジー入門
|
ユーザー |
![]() |
提出日時 | 2024-10-04 21:29:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,217 bytes |
コンパイル時間 | 2,233 ms |
コンパイル使用メモリ | 206,992 KB |
最終ジャッジ日時 | 2025-02-24 15:02:33 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 47 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ALL(v) v.begin(),v.end() #define dbg(x) cerr << #x << ": " << (x) << endl; int n,m; vector<vector<int>> g; vector<int> v(3); int main() { cin >> n >> m; g.resize(n, vector<int>(n)); for (int i = 0; i < m; ++i) { int a,b; cin >> a >> b; g[a][b] = g[b][a] = 1; } for (int &i : v) cin >> i; sort(ALL(v)); for (int i = 1; i < 1<<n; ++i) { vector<int> p; for (int j = 0; j < n; ++j) { if (i >> j & 1) p.push_back(j); } if (p == v) continue; if (p.size() <= 2) continue; do { bool ok = true; for (int j = 0; j < p.size(); ++j) { int nx = p[(j+1) % p.size()]; if (g[p[j]][nx] == 0) { ok = false; break; } } if (ok) { // for (int j = 0; j < p.size(); ++j) { // cerr << p[j] << " \n"[j==p.size()-1]; // } cout << "Yes\n"; return 0; } } while (next_permutation(ALL(p))); } cout << "No\n"; }