| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 959166 | Ariadna | Geppetto (COCI15_geppetto) | C++14 | 89 ms | 4544 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int pizzas(int n, vector<vector<int>>& mixing) {
    priority_queue<int> pq;
    vector<int> visited(1<<n, 0);
    pq.push(0);
    int ans = 1;
    while (!pq.empty()) {
        int mask = pq.top();
        pq.pop();
        for (int i = 0; i < n; ++i) {
            if (mask & (1<<i) || visited[mask | (1<<i)]) continue;
            bool control = true;
            for (int j = 0; j < n; ++j) {
                if ((mask & (1<<j)) && mixing[i][j]) control = false;
            }
            int new_mask = mask | (1<<i);
            if (control) {
                ++ans;
                pq.push(new_mask);
            }
            visited[new_mask] = 1;
        }
    }
    return ans;
}
int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> mixing(n, vector<int>(n, 0));
    while (m--) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        mixing[a][b] = mixing[b][a] = 1;
    }
    cout << pizzas(n, mixing) << '\n';
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
