답안 #785761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
785761 2023-07-17T14:43:37 Z SlavicG Political Development (BOI17_politicaldevelopment) C++17
4 / 100
3000 ms 26104 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()

const int N = 5e4 + 10;
unordered_set<int> st[N];
vector<int> adj[N];
int ans = 1;

void solve() {
    int n, k; cin >> n >> k;
    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);
            }
        } 
    }
    
    for(int i = 0; i < n; ++i) {
        if(sz(adj[i]) >= k) {
            ans = max(ans, 2);
            continue;
        }
        vector<int> dp(1 << (sz(adj[i])), 0);
        dp[0] = 1;
        for(int mask = 1; mask < (1 << (sz(adj[i]))); ++mask) {
            for(int j = 0; j < sz(adj[i]); ++j) {
                if(mask >> j & 1) {
                    bool ok = 1;
                    for(int f = 0; f < sz(adj[i]); ++f) {
                        if(f == j) continue;
                        if(mask >> f & 1) {
                            if(st[adj[i][j]].find(adj[i][f]) == st[adj[i][j]].end()) ok = false;
                        }
                    }
                    if(ok) dp[mask] |= dp[mask ^ (1 << j)];
                }
            }
            if(dp[mask]) {
                ans = max(ans, 1 + __builtin_popcount(mask));
            }
        }
    }
    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 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 5 ms 5204 KB Output is correct
4 Correct 6 ms 5256 KB Output is correct
5 Correct 5 ms 5204 KB Output is correct
6 Correct 5 ms 5272 KB Output is correct
7 Correct 5 ms 5332 KB Output is correct
8 Correct 2 ms 4180 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 5 ms 5204 KB Output is correct
4 Correct 6 ms 5256 KB Output is correct
5 Correct 5 ms 5204 KB Output is correct
6 Correct 5 ms 5272 KB Output is correct
7 Correct 5 ms 5332 KB Output is correct
8 Correct 2 ms 4180 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 5 ms 5204 KB Output is correct
12 Correct 5 ms 5204 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 5 ms 5204 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 6 ms 5332 KB Output is correct
17 Correct 3 ms 4180 KB Output is correct
18 Correct 5 ms 5252 KB Output is correct
19 Correct 2 ms 4180 KB Output is correct
20 Correct 4 ms 5076 KB Output is correct
21 Correct 4 ms 5076 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Incorrect 6 ms 5284 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4232 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 2 ms 4180 KB Output is correct
4 Correct 2 ms 4180 KB Output is correct
5 Correct 2 ms 4180 KB Output is correct
6 Correct 3 ms 4180 KB Output is correct
7 Correct 2 ms 4180 KB Output is correct
8 Correct 3 ms 4180 KB Output is correct
9 Correct 2 ms 4240 KB Output is correct
10 Correct 2 ms 4180 KB Output is correct
11 Execution timed out 3065 ms 26104 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 5 ms 5204 KB Output is correct
4 Correct 6 ms 5256 KB Output is correct
5 Correct 5 ms 5204 KB Output is correct
6 Correct 5 ms 5272 KB Output is correct
7 Correct 5 ms 5332 KB Output is correct
8 Correct 2 ms 4180 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 5 ms 5204 KB Output is correct
12 Correct 5 ms 5204 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 5 ms 5204 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 6 ms 5332 KB Output is correct
17 Correct 3 ms 4180 KB Output is correct
18 Correct 5 ms 5252 KB Output is correct
19 Correct 2 ms 4180 KB Output is correct
20 Correct 4 ms 5076 KB Output is correct
21 Correct 4 ms 5076 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Incorrect 6 ms 5284 KB Output isn't correct
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4180 KB Output is correct
3 Correct 5 ms 5204 KB Output is correct
4 Correct 6 ms 5256 KB Output is correct
5 Correct 5 ms 5204 KB Output is correct
6 Correct 5 ms 5272 KB Output is correct
7 Correct 5 ms 5332 KB Output is correct
8 Correct 2 ms 4180 KB Output is correct
9 Correct 2 ms 4180 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 5 ms 5204 KB Output is correct
12 Correct 5 ms 5204 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 5 ms 5204 KB Output is correct
15 Correct 2 ms 4180 KB Output is correct
16 Correct 6 ms 5332 KB Output is correct
17 Correct 3 ms 4180 KB Output is correct
18 Correct 5 ms 5252 KB Output is correct
19 Correct 2 ms 4180 KB Output is correct
20 Correct 4 ms 5076 KB Output is correct
21 Correct 4 ms 5076 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Incorrect 6 ms 5284 KB Output isn't correct
24 Halted 0 ms 0 KB -