結果

問題 No.2910 単体ホモロジー入門
ユーザー Carpenters-Cat
提出日時 2024-10-04 22:07:14
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 836 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 195,820 KB
最終ジャッジ日時 2025-02-24 15:19:21
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#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() < 2) 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;
}
0