結果

問題 No.2910 単体ホモロジー入門
ユーザー eve__fuyuki
提出日時 2024-10-07 01:39:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,057 bytes
コンパイル時間 2,005 ms
コンパイル使用メモリ 200,364 KB
最終ジャッジ日時 2025-02-24 16:14:47
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void fast_io() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main() {
	fast_io();
	int n, m;
	cin >> n >> m;
	bool g[n][n] = {};
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		g[a][b] = g[b][a] = true;
	}
	set<int> v;
	for (int i = 0; i < 3; i++) {
		int a;
		cin >> a;
		v.insert(a);
	}
	int p[n];
	iota(p, p + n, 0);
	do {
		bool ok = true;
		for (int i = 0; i < n; i++) {
			if (!g[p[i]][p[(i + 1) % n]]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			set<int> st;
			for (int i = 0; i < 3; i++) {
				st.insert(p[i]);
			}
			if (st != v) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		if (n == 4) {
			bool ok = true;
			for (int i = 0; i < 3; i++) {
				if (!g[p[i]][p[(i + 1) % 3]]) {
					ok = false;
					break;
				}
			}
			if (ok) {
				set<int> st;
				for (int i = 0; i < 3; i++) {
					st.insert(p[i]);
				}
				if (st != v) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	} while (next_permutation(p, p + n));
	cout << "No" << endl;
}
0