답안 #252692

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252692 2020-07-26T06:46:11 Z NONAME Geppetto (COCI15_geppetto) C++14
80 / 80
450 ms 504 KB
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;

bool mk[30];
int n, m;
vector <int> g[30];

void dfs(int v) {
    if (mk[v])
        return;

    mk[v] = 1;
    for (int u : g[v])
        dfs(u);
}

int main() {
    fast_io;

    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        --x, --y;

        g[x].push_back(y);
        g[y].push_back(x);
    }

    for (int i = 0; i < n; ++i)
        sort(g[i].begin(), g[i].end());

    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
        vector <int> vec;

        for (int j = 0; j < n; ++j)
            mk[j] = 0;

        for (int j = 0; j < n; ++j)
            if (i & (1 << j))
                vec.push_back(j), mk[j] = 1;

        int f = 1;
        for (int x : vec) {
            for (int y : g[x])
                if (mk[y])
                    f = 0;
            if (!f) break;
        }

        ans += f;
    }

    cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 450 ms 388 KB Output is correct
4 Correct 410 ms 504 KB Output is correct
5 Correct 387 ms 388 KB Output is correct
6 Correct 356 ms 504 KB Output is correct
7 Correct 355 ms 376 KB Output is correct
8 Correct 368 ms 376 KB Output is correct
9 Correct 363 ms 384 KB Output is correct
10 Correct 365 ms 384 KB Output is correct