# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
203624 | 2020-02-21T16:18:23 Z | karma | Political Development (BOI17_politicaldevelopment) | C++14 | 23 ms | 2936 KB |
#include<bits/stdc++.h> #define ll long long #define pb emplace_back #define fi first #define se second #define mp make_pair //#define int int64_t using namespace std; typedef pair<int, int> pii; const int N = (int)5e4 + 2; priority_queue<pii, vector<pii>, greater<pii>> pq; int n, k, d, u, cnt, res, ans; int deg[N], f[N], lab[N], id[N]; bool del[N], ok; vector<int> adj[N]; map<pii, bool> edges; pii top; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define FileName "test" if(fopen(FileName".inp", "r")) { freopen(FileName".inp", "r", stdin); freopen(FileName".out", "w", stdout); } cin >> n >> k; for(int i = 1; i <= n; ++i) { cin >> d; adj[i].resize(d); for(int& c: adj[i]) cin >> c, edges[{c, i}] = 1; deg[i] = d; pq.push(mp(deg[i], i)); } res = 1; while(pq.size()) { top = pq.top(); pq.pop(); if(top.fi != deg[top.se]) continue; u = top.se; cnt = 0; for(int v: adj[u]) { if(del[v]) continue; id[lab[v] = cnt ++] = v; } for(int i = 0; i < (1 << cnt); ++i) { if((ans = __builtin_popcount(i)) < res) continue; ok = 1; for(int j = 0; j < cnt; ++j) { if(!(i >> j & 1)) continue; for(int k = j + 1; k < cnt; ++k) { if((i >> k & 1) && !edges[{id[j], id[k]}]) ok = 0; } if(!ok) break; } if(ok) res = ans + 1; } } cout << min(res, k); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1528 KB | Output is correct |
2 | Correct | 5 ms | 1528 KB | Output is correct |
3 | Correct | 23 ms | 2936 KB | Output is correct |
4 | Correct | 18 ms | 2808 KB | Output is correct |
5 | Correct | 19 ms | 2680 KB | Output is correct |
6 | Correct | 22 ms | 2808 KB | Output is correct |
7 | Correct | 22 ms | 2808 KB | Output is correct |
8 | Correct | 6 ms | 1656 KB | Output is correct |
9 | Correct | 5 ms | 1528 KB | Output is correct |
10 | Correct | 6 ms | 1656 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1528 KB | Output is correct |
2 | Correct | 5 ms | 1528 KB | Output is correct |
3 | Correct | 23 ms | 2936 KB | Output is correct |
4 | Correct | 18 ms | 2808 KB | Output is correct |
5 | Correct | 19 ms | 2680 KB | Output is correct |
6 | Correct | 22 ms | 2808 KB | Output is correct |
7 | Correct | 22 ms | 2808 KB | Output is correct |
8 | Correct | 6 ms | 1656 KB | Output is correct |
9 | Correct | 5 ms | 1528 KB | Output is correct |
10 | Correct | 6 ms | 1656 KB | Output is correct |
11 | Correct | 20 ms | 2680 KB | Output is correct |
12 | Correct | 20 ms | 2808 KB | Output is correct |
13 | Incorrect | 5 ms | 1528 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 7 ms | 1656 KB | Output is correct |
2 | Incorrect | 5 ms | 1532 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1528 KB | Output is correct |
2 | Correct | 5 ms | 1528 KB | Output is correct |
3 | Correct | 23 ms | 2936 KB | Output is correct |
4 | Correct | 18 ms | 2808 KB | Output is correct |
5 | Correct | 19 ms | 2680 KB | Output is correct |
6 | Correct | 22 ms | 2808 KB | Output is correct |
7 | Correct | 22 ms | 2808 KB | Output is correct |
8 | Correct | 6 ms | 1656 KB | Output is correct |
9 | Correct | 5 ms | 1528 KB | Output is correct |
10 | Correct | 6 ms | 1656 KB | Output is correct |
11 | Correct | 20 ms | 2680 KB | Output is correct |
12 | Correct | 20 ms | 2808 KB | Output is correct |
13 | Incorrect | 5 ms | 1528 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1528 KB | Output is correct |
2 | Correct | 5 ms | 1528 KB | Output is correct |
3 | Correct | 23 ms | 2936 KB | Output is correct |
4 | Correct | 18 ms | 2808 KB | Output is correct |
5 | Correct | 19 ms | 2680 KB | Output is correct |
6 | Correct | 22 ms | 2808 KB | Output is correct |
7 | Correct | 22 ms | 2808 KB | Output is correct |
8 | Correct | 6 ms | 1656 KB | Output is correct |
9 | Correct | 5 ms | 1528 KB | Output is correct |
10 | Correct | 6 ms | 1656 KB | Output is correct |
11 | Correct | 20 ms | 2680 KB | Output is correct |
12 | Correct | 20 ms | 2808 KB | Output is correct |
13 | Incorrect | 5 ms | 1528 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |