結果

問題 No.2910 単体ホモロジー入門
ユーザー Tatsu_mr
提出日時 2024-10-04 21:35:15
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 2,829 ms
コンパイル使用メモリ 257,204 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-04 21:35:22
合計ジャッジ時間 3,852 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for(long long i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;

using lint = long long;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<bool>> g(n, vector<bool>(n, false));
    rep(_, m) {
        int i, j;
        cin >> i >> j;
        g[i][j] = g[j][i] = true;
    }
    vector<int> v(3);
    rep(i, 3) {
        cin >> v[i];
    }
    sort(ALL(v));
    vector<int> id(n);
    rep(i, n) {
        id[i] = i;
    }
    bool ans = false;
    do {
        for (int sz = 3; sz <= n; sz++) {
            bool same = false;
            if (sz == 3) {
                vector<int> v2 = {id[0], id[1], id[2]};
                sort(ALL(v2));
                if (v == v2) {
                    same = true;
                }
            }
            if (same) {
                continue;
            }
            bool ok = true;
            rep(i, sz) {
                if (!g[id[i]][id[(i + 1) % sz]]) {
                    ok = false;
                }
            }
            if (ok) {
                ans = true;
            }
        }
    } while (next_permutation(ALL(id)));
    cout << (ans ? "Yes" : "No") << endl;
}
0