답안 #785579

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
785579 2023-07-17T10:22:21 Z SlavicG Political Development (BOI17_politicaldevelopment) C++17
39 / 100
441 ms 26140 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()
 
void solve() {
    int n, k; cin >> n >> k;
    unordered_set<int> st[n + 1];
    vector<vector<int>> adj(n);
    for(int i = 0; i < n; ++i) {
        int x; cin >> x; 
        if(x >= 1) {
            adj[i].resize(x);
            for(int j = 0; j < x; ++j) {
                cin >> adj[i][j];
                st[i].insert(adj[i][j]);
                st[adj[i][j]].insert(i);
            }
        } 
    }
    int ans = 1;
    for(int i = 0; i < n; ++i) {
        if(sz(adj[i]) > k) continue;
        vector<int> dp(1 << (sz(adj[i])), 0);
        dp[0] = 1;
        for(int mask = 0; mask < (1 << (sz(adj[i]))); ++mask) {
            if(!dp[mask]) continue;
            int cnt = 1;
            for(int f = 0; f < sz(adj[i]); ++f) {
                if(mask >> f & 1) ++cnt;
            }
            ans = max(ans, cnt);
            for(int j = 0; j < sz(adj[i]); ++j) {
                if(mask >> j & 1) continue;
                bool check = true;
                for(int f = 0; f < sz(adj[i]); ++f) {
                    if(mask >> f & 1) {
                        if(st[adj[i][j]].find(adj[i][f]) == st[adj[i][j]].end()) check = false;
                    }
                }
                if(check) dp[mask | (1 << j)] = 1;
            }
        }
    }
    cout << ans << "\n";
}   
 
int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 1724 KB Output is correct
4 Correct 3 ms 1748 KB Output is correct
5 Correct 3 ms 1748 KB Output is correct
6 Correct 4 ms 1748 KB Output is correct
7 Correct 4 ms 1748 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 1724 KB Output is correct
4 Correct 3 ms 1748 KB Output is correct
5 Correct 3 ms 1748 KB Output is correct
6 Correct 4 ms 1748 KB Output is correct
7 Correct 4 ms 1748 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 5 ms 1700 KB Output is correct
12 Correct 3 ms 1748 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 3 ms 1748 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 1748 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 4 ms 1748 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 3 ms 1552 KB Output is correct
21 Correct 3 ms 1492 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 4 ms 1748 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 5 ms 1876 KB Output is correct
26 Correct 4 ms 1708 KB Output is correct
27 Correct 4 ms 1748 KB Output is correct
28 Correct 4 ms 1740 KB Output is correct
29 Correct 4 ms 1748 KB Output is correct
30 Correct 4 ms 1876 KB Output is correct
31 Correct 5 ms 1876 KB Output is correct
32 Correct 4 ms 1876 KB Output is correct
33 Correct 4 ms 1876 KB Output is correct
34 Correct 5 ms 1876 KB Output is correct
35 Correct 2 ms 1096 KB Output is correct
36 Correct 2 ms 980 KB Output is correct
37 Correct 3 ms 1108 KB Output is correct
38 Correct 2 ms 724 KB Output is correct
39 Correct 2 ms 724 KB Output is correct
40 Correct 6 ms 2124 KB Output is correct
41 Correct 2 ms 724 KB Output is correct
42 Correct 5 ms 2132 KB Output is correct
43 Correct 6 ms 2132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 244 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 417 ms 26060 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 417 ms 26140 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 391 ms 26040 KB Output is correct
16 Correct 432 ms 26056 KB Output is correct
17 Correct 433 ms 26140 KB Output is correct
18 Correct 441 ms 26080 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 1724 KB Output is correct
4 Correct 3 ms 1748 KB Output is correct
5 Correct 3 ms 1748 KB Output is correct
6 Correct 4 ms 1748 KB Output is correct
7 Correct 4 ms 1748 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 5 ms 1700 KB Output is correct
12 Correct 3 ms 1748 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 3 ms 1748 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 1748 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 4 ms 1748 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 3 ms 1552 KB Output is correct
21 Correct 3 ms 1492 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 4 ms 1748 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 5 ms 1876 KB Output is correct
26 Correct 4 ms 1708 KB Output is correct
27 Correct 4 ms 1748 KB Output is correct
28 Correct 4 ms 1740 KB Output is correct
29 Correct 4 ms 1748 KB Output is correct
30 Correct 4 ms 1876 KB Output is correct
31 Correct 5 ms 1876 KB Output is correct
32 Correct 4 ms 1876 KB Output is correct
33 Correct 4 ms 1876 KB Output is correct
34 Correct 5 ms 1876 KB Output is correct
35 Correct 2 ms 1096 KB Output is correct
36 Correct 2 ms 980 KB Output is correct
37 Correct 3 ms 1108 KB Output is correct
38 Correct 2 ms 724 KB Output is correct
39 Correct 2 ms 724 KB Output is correct
40 Correct 6 ms 2124 KB Output is correct
41 Correct 2 ms 724 KB Output is correct
42 Correct 5 ms 2132 KB Output is correct
43 Correct 6 ms 2132 KB Output is correct
44 Correct 282 ms 2916 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Incorrect 6 ms 2132 KB Output isn't correct
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 1724 KB Output is correct
4 Correct 3 ms 1748 KB Output is correct
5 Correct 3 ms 1748 KB Output is correct
6 Correct 4 ms 1748 KB Output is correct
7 Correct 4 ms 1748 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 596 KB Output is correct
11 Correct 5 ms 1700 KB Output is correct
12 Correct 3 ms 1748 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 3 ms 1748 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 4 ms 1748 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 4 ms 1748 KB Output is correct
19 Correct 1 ms 596 KB Output is correct
20 Correct 3 ms 1552 KB Output is correct
21 Correct 3 ms 1492 KB Output is correct
22 Correct 1 ms 596 KB Output is correct
23 Correct 4 ms 1748 KB Output is correct
24 Correct 1 ms 596 KB Output is correct
25 Correct 5 ms 1876 KB Output is correct
26 Correct 4 ms 1708 KB Output is correct
27 Correct 4 ms 1748 KB Output is correct
28 Correct 4 ms 1740 KB Output is correct
29 Correct 4 ms 1748 KB Output is correct
30 Correct 4 ms 1876 KB Output is correct
31 Correct 5 ms 1876 KB Output is correct
32 Correct 4 ms 1876 KB Output is correct
33 Correct 4 ms 1876 KB Output is correct
34 Correct 5 ms 1876 KB Output is correct
35 Correct 2 ms 1096 KB Output is correct
36 Correct 2 ms 980 KB Output is correct
37 Correct 3 ms 1108 KB Output is correct
38 Correct 2 ms 724 KB Output is correct
39 Correct 2 ms 724 KB Output is correct
40 Correct 6 ms 2124 KB Output is correct
41 Correct 2 ms 724 KB Output is correct
42 Correct 5 ms 2132 KB Output is correct
43 Correct 6 ms 2132 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Incorrect 127 ms 22988 KB Output isn't correct
46 Halted 0 ms 0 KB -