結果
問題 | No.2910 単体ホモロジー入門 |
ユーザー |
|
提出日時 | 2024-10-04 22:16:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 836 bytes |
コンパイル時間 | 1,861 ms |
コンパイル使用メモリ | 196,836 KB |
最終ジャッジ日時 | 2025-02-24 15:22:53 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 47 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main () {int N, M;cin >> N >> M;int OK[5][5];for (auto& a : OK) {for (auto& b : a) {b = 0;}}while(M--) {int a, b;cin >> a >> b;OK[a][b] = OK[b][a] = 1;}int ng = 0;for (int i = 0; i < 3; i ++) {int a;cin >> a;ng |= (1 << a);}for (int s = 1; s < (1 << N); s ++) {if (s == ng) continue;std::vector<int> A;for (int i = 0; i < N; i ++) {if ((s >> i) & 1) {A.push_back(i);}}if (A.size() < 3) continue;bool ok = false;do {bool x = true;for (int i = 1; i < A.size(); i ++) {x = x && (OK[A[i-1]][A[i]] == 1);}x = x && (OK[A[0]][A.back()] == 1);ok = ok || x;} while (next_permutation(A.begin(), A.end()));if (ok) {puts("Yes");return 0;}}puts("No");// return 139;}