# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
933753 | 2024-02-26T09:03:17 Z | LucaIlie | Political Development (BOI17_politicaldevelopment) | C++17 | 3000 ms | 25076 KB |
#include <bits/stdc++.h> using namespace std; struct pv { int u, a; bool operator < ( const pv &x ) const { if ( a == x.a ) return u < x.u; return a < x.a; } }; const int MAX_N = 5e4; const int MAX_K = 10; int perm[MAX_N], pos[MAX_N]; unordered_set<int> adj[MAX_N]; set<pv> vertMinSize; int solve( vector<int> vertices ) { int n = vertices.size(); for ( int i = 0; i < n; i++ ) pos[vertices[i]] = i; int ans = 0; for ( int mask = 0; mask < (1 << n); mask++ ) { vector<int> v; for ( int i = 0; i < n; i++ ) { if ( (mask >> i) & 1) v.push_back( vertices[i] ); } bool ok = true; for ( int x: v ) { for ( int y: v ) { if ( x != y && adj[x].find( y ) == adj[x].end() ) ok = false; } } if ( ok ) ans = max( ans, (int)v.size() ); } for ( int i = 0; i < n; i++ ) pos[vertices[i]] = -1; return ans; } int main() { int n, k, minn = n; cin >> n >> k; for ( int u = 0; u < n; u++ ) { int d; cin >> d; for ( int j = 0; j < d; j++ ) { int v; cin >> v; adj[u].insert( v ); } minn = min( minn, d ); vertMinSize.insert( { u, d } ); } for ( int i = 0; i < n; i++ ) pos[i] = -1; if ( minn > k ) exit( 1 ); int ans = 0; for ( int i = 0; i < n; i++ ) { int u = vertMinSize.begin()->u; vector<int> vertices; vertices.push_back( u ); for ( int v: adj[u] ) vertices.push_back( v ); ans = max( ans, solve( vertices ) ); vertMinSize.erase( { u, (int)adj[u].size() } ); adj[u].clear(); for ( int v: adj[u] ) { vertMinSize.erase( { v, (int)adj[v].size() } ); adj[v].erase( u ); vertMinSize.insert( { v, (int)adj[v].size() } ); } } cout << ans; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 3160 KB | Output is correct |
2 | Correct | 1 ms | 3164 KB | Output is correct |
3 | Correct | 27 ms | 4256 KB | Output is correct |
4 | Correct | 611 ms | 4188 KB | Output is correct |
5 | Correct | 612 ms | 4188 KB | Output is correct |
6 | Correct | 36 ms | 4184 KB | Output is correct |
7 | Correct | 37 ms | 4344 KB | Output is correct |
8 | Correct | 3 ms | 3416 KB | Output is correct |
9 | Correct | 1 ms | 3164 KB | Output is correct |
10 | Correct | 3 ms | 3348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 3160 KB | Output is correct |
2 | Correct | 1 ms | 3164 KB | Output is correct |
3 | Correct | 27 ms | 4256 KB | Output is correct |
4 | Correct | 611 ms | 4188 KB | Output is correct |
5 | Correct | 612 ms | 4188 KB | Output is correct |
6 | Correct | 36 ms | 4184 KB | Output is correct |
7 | Correct | 37 ms | 4344 KB | Output is correct |
8 | Correct | 3 ms | 3416 KB | Output is correct |
9 | Correct | 1 ms | 3164 KB | Output is correct |
10 | Correct | 3 ms | 3348 KB | Output is correct |
11 | Correct | 615 ms | 4440 KB | Output is correct |
12 | Correct | 610 ms | 4364 KB | Output is correct |
13 | Correct | 1 ms | 3160 KB | Output is correct |
14 | Correct | 613 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 3164 KB | Output is correct |
16 | Correct | 36 ms | 4188 KB | Output is correct |
17 | Correct | 1 ms | 3164 KB | Output is correct |
18 | Correct | 36 ms | 4356 KB | Output is correct |
19 | Correct | 3 ms | 3416 KB | Output is correct |
20 | Correct | 5 ms | 3932 KB | Output is correct |
21 | Correct | 5 ms | 3932 KB | Output is correct |
22 | Correct | 3 ms | 3416 KB | Output is correct |
23 | Correct | 16 ms | 4372 KB | Output is correct |
24 | Correct | 3 ms | 3420 KB | Output is correct |
25 | Correct | 18 ms | 4144 KB | Output is correct |
26 | Correct | 14 ms | 4324 KB | Output is correct |
27 | Correct | 7 ms | 4188 KB | Output is correct |
28 | Correct | 14 ms | 4320 KB | Output is correct |
29 | Correct | 7 ms | 4188 KB | Output is correct |
30 | Correct | 10 ms | 4440 KB | Output is correct |
31 | Correct | 14 ms | 4440 KB | Output is correct |
32 | Correct | 14 ms | 4444 KB | Output is correct |
33 | Correct | 13 ms | 4188 KB | Output is correct |
34 | Correct | 13 ms | 4316 KB | Output is correct |
35 | Correct | 7 ms | 3676 KB | Output is correct |
36 | Correct | 7 ms | 3676 KB | Output is correct |
37 | Correct | 7 ms | 3676 KB | Output is correct |
38 | Execution timed out | 3080 ms | 3420 KB | Time limit exceeded |
39 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 3420 KB | Output is correct |
2 | Correct | 1 ms | 3164 KB | Output is correct |
3 | Correct | 1 ms | 3164 KB | Output is correct |
4 | Correct | 1 ms | 3164 KB | Output is correct |
5 | Correct | 1 ms | 3164 KB | Output is correct |
6 | Correct | 2 ms | 3164 KB | Output is correct |
7 | Correct | 1 ms | 3164 KB | Output is correct |
8 | Correct | 1 ms | 3164 KB | Output is correct |
9 | Correct | 1 ms | 3164 KB | Output is correct |
10 | Correct | 1 ms | 3164 KB | Output is correct |
11 | Execution timed out | 3053 ms | 25076 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 3160 KB | Output is correct |
2 | Correct | 1 ms | 3164 KB | Output is correct |
3 | Correct | 27 ms | 4256 KB | Output is correct |
4 | Correct | 611 ms | 4188 KB | Output is correct |
5 | Correct | 612 ms | 4188 KB | Output is correct |
6 | Correct | 36 ms | 4184 KB | Output is correct |
7 | Correct | 37 ms | 4344 KB | Output is correct |
8 | Correct | 3 ms | 3416 KB | Output is correct |
9 | Correct | 1 ms | 3164 KB | Output is correct |
10 | Correct | 3 ms | 3348 KB | Output is correct |
11 | Correct | 615 ms | 4440 KB | Output is correct |
12 | Correct | 610 ms | 4364 KB | Output is correct |
13 | Correct | 1 ms | 3160 KB | Output is correct |
14 | Correct | 613 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 3164 KB | Output is correct |
16 | Correct | 36 ms | 4188 KB | Output is correct |
17 | Correct | 1 ms | 3164 KB | Output is correct |
18 | Correct | 36 ms | 4356 KB | Output is correct |
19 | Correct | 3 ms | 3416 KB | Output is correct |
20 | Correct | 5 ms | 3932 KB | Output is correct |
21 | Correct | 5 ms | 3932 KB | Output is correct |
22 | Correct | 3 ms | 3416 KB | Output is correct |
23 | Correct | 16 ms | 4372 KB | Output is correct |
24 | Correct | 3 ms | 3420 KB | Output is correct |
25 | Correct | 18 ms | 4144 KB | Output is correct |
26 | Correct | 14 ms | 4324 KB | Output is correct |
27 | Correct | 7 ms | 4188 KB | Output is correct |
28 | Correct | 14 ms | 4320 KB | Output is correct |
29 | Correct | 7 ms | 4188 KB | Output is correct |
30 | Correct | 10 ms | 4440 KB | Output is correct |
31 | Correct | 14 ms | 4440 KB | Output is correct |
32 | Correct | 14 ms | 4444 KB | Output is correct |
33 | Correct | 13 ms | 4188 KB | Output is correct |
34 | Correct | 13 ms | 4316 KB | Output is correct |
35 | Correct | 7 ms | 3676 KB | Output is correct |
36 | Correct | 7 ms | 3676 KB | Output is correct |
37 | Correct | 7 ms | 3676 KB | Output is correct |
38 | Execution timed out | 3080 ms | 3420 KB | Time limit exceeded |
39 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 3160 KB | Output is correct |
2 | Correct | 1 ms | 3164 KB | Output is correct |
3 | Correct | 27 ms | 4256 KB | Output is correct |
4 | Correct | 611 ms | 4188 KB | Output is correct |
5 | Correct | 612 ms | 4188 KB | Output is correct |
6 | Correct | 36 ms | 4184 KB | Output is correct |
7 | Correct | 37 ms | 4344 KB | Output is correct |
8 | Correct | 3 ms | 3416 KB | Output is correct |
9 | Correct | 1 ms | 3164 KB | Output is correct |
10 | Correct | 3 ms | 3348 KB | Output is correct |
11 | Correct | 615 ms | 4440 KB | Output is correct |
12 | Correct | 610 ms | 4364 KB | Output is correct |
13 | Correct | 1 ms | 3160 KB | Output is correct |
14 | Correct | 613 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 3164 KB | Output is correct |
16 | Correct | 36 ms | 4188 KB | Output is correct |
17 | Correct | 1 ms | 3164 KB | Output is correct |
18 | Correct | 36 ms | 4356 KB | Output is correct |
19 | Correct | 3 ms | 3416 KB | Output is correct |
20 | Correct | 5 ms | 3932 KB | Output is correct |
21 | Correct | 5 ms | 3932 KB | Output is correct |
22 | Correct | 3 ms | 3416 KB | Output is correct |
23 | Correct | 16 ms | 4372 KB | Output is correct |
24 | Correct | 3 ms | 3420 KB | Output is correct |
25 | Correct | 18 ms | 4144 KB | Output is correct |
26 | Correct | 14 ms | 4324 KB | Output is correct |
27 | Correct | 7 ms | 4188 KB | Output is correct |
28 | Correct | 14 ms | 4320 KB | Output is correct |
29 | Correct | 7 ms | 4188 KB | Output is correct |
30 | Correct | 10 ms | 4440 KB | Output is correct |
31 | Correct | 14 ms | 4440 KB | Output is correct |
32 | Correct | 14 ms | 4444 KB | Output is correct |
33 | Correct | 13 ms | 4188 KB | Output is correct |
34 | Correct | 13 ms | 4316 KB | Output is correct |
35 | Correct | 7 ms | 3676 KB | Output is correct |
36 | Correct | 7 ms | 3676 KB | Output is correct |
37 | Correct | 7 ms | 3676 KB | Output is correct |
38 | Execution timed out | 3080 ms | 3420 KB | Time limit exceeded |
39 | Halted | 0 ms | 0 KB | - |