제출 #959166

#제출 시각아이디문제언어결과실행 시간메모리
959166AriadnaGeppetto (COCI15_geppetto)C++14
80 / 80
89 ms4544 KiB
#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 timeMemoryGrader output
Fetching results...