Submission #785643

# Submission time Handle Problem Language Result Execution time Memory
785643 2023-07-17T11:10:02 Z SlavicG Political Development (BOI17_politicaldevelopment) C++17
39 / 100
247 ms 44348 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];
int ans = 1;
vector<int> adj[N];
bool vis[N];
void dfs(int u, set<int> nodes) {
    ans = max(sz(nodes), ans);
    vis[u] = true;
    for(int v: adj[u]) {
        if(vis[v]) continue;
        set<int> newset = nodes; newset.insert(v);
        for(auto x: nodes) if(st[v].find(x) == st[v].end()) newset.erase(x);
        dfs(v, newset); 
    }
} 
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) 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;
            }
        }
    }
    if(ans == k) {
        cout << ans;
        return;
    }
    */
    for(int i = 0; i < n; ++i) {
        if(!vis[i]) dfs(i, {i});
    }
    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();
    }
}
# Verdict Execution time Memory 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 5 ms 5276 KB Output is correct
5 Correct 5 ms 5328 KB Output is correct
6 Correct 5 ms 5332 KB Output is correct
7 Correct 6 ms 5404 KB Output is correct
8 Correct 2 ms 4248 KB Output is correct
9 Correct 2 ms 4240 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
# Verdict Execution time Memory 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 5 ms 5276 KB Output is correct
5 Correct 5 ms 5328 KB Output is correct
6 Correct 5 ms 5332 KB Output is correct
7 Correct 6 ms 5404 KB Output is correct
8 Correct 2 ms 4248 KB Output is correct
9 Correct 2 ms 4240 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 6 ms 5332 KB Output is correct
12 Correct 5 ms 5276 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 5 ms 5324 KB Output is correct
15 Correct 2 ms 4240 KB Output is correct
16 Correct 5 ms 5332 KB Output is correct
17 Correct 2 ms 4240 KB Output is correct
18 Correct 6 ms 5332 KB Output is correct
19 Correct 2 ms 4244 KB Output is correct
20 Correct 4 ms 5152 KB Output is correct
21 Correct 4 ms 5076 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Correct 6 ms 6100 KB Output is correct
24 Correct 2 ms 4252 KB Output is correct
25 Correct 6 ms 6100 KB Output is correct
26 Correct 6 ms 5844 KB Output is correct
27 Correct 8 ms 7252 KB Output is correct
28 Correct 6 ms 5844 KB Output is correct
29 Correct 6 ms 7324 KB Output is correct
30 Correct 6 ms 5460 KB Output is correct
31 Correct 7 ms 6356 KB Output is correct
32 Correct 6 ms 5408 KB Output is correct
33 Correct 7 ms 6432 KB Output is correct
34 Correct 6 ms 6484 KB Output is correct
35 Correct 5 ms 5400 KB Output is correct
36 Correct 5 ms 5272 KB Output is correct
37 Correct 4 ms 5332 KB Output is correct
38 Correct 3 ms 4564 KB Output is correct
39 Correct 4 ms 4652 KB Output is correct
40 Correct 7 ms 6548 KB Output is correct
41 Correct 3 ms 4564 KB Output is correct
42 Correct 7 ms 6560 KB Output is correct
43 Correct 7 ms 6560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4180 KB Output is correct
2 Correct 2 ms 4240 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 2 ms 4180 KB Output is correct
7 Correct 2 ms 4180 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 221 ms 44348 KB Output is correct
12 Correct 2 ms 4180 KB Output is correct
13 Correct 247 ms 43868 KB Output is correct
14 Correct 2 ms 4180 KB Output is correct
15 Correct 224 ms 43960 KB Output is correct
16 Correct 219 ms 43932 KB Output is correct
17 Correct 195 ms 43804 KB Output is correct
18 Correct 194 ms 44020 KB Output is correct
# Verdict Execution time Memory 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 5 ms 5276 KB Output is correct
5 Correct 5 ms 5328 KB Output is correct
6 Correct 5 ms 5332 KB Output is correct
7 Correct 6 ms 5404 KB Output is correct
8 Correct 2 ms 4248 KB Output is correct
9 Correct 2 ms 4240 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 6 ms 5332 KB Output is correct
12 Correct 5 ms 5276 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 5 ms 5324 KB Output is correct
15 Correct 2 ms 4240 KB Output is correct
16 Correct 5 ms 5332 KB Output is correct
17 Correct 2 ms 4240 KB Output is correct
18 Correct 6 ms 5332 KB Output is correct
19 Correct 2 ms 4244 KB Output is correct
20 Correct 4 ms 5152 KB Output is correct
21 Correct 4 ms 5076 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Correct 6 ms 6100 KB Output is correct
24 Correct 2 ms 4252 KB Output is correct
25 Correct 6 ms 6100 KB Output is correct
26 Correct 6 ms 5844 KB Output is correct
27 Correct 8 ms 7252 KB Output is correct
28 Correct 6 ms 5844 KB Output is correct
29 Correct 6 ms 7324 KB Output is correct
30 Correct 6 ms 5460 KB Output is correct
31 Correct 7 ms 6356 KB Output is correct
32 Correct 6 ms 5408 KB Output is correct
33 Correct 7 ms 6432 KB Output is correct
34 Correct 6 ms 6484 KB Output is correct
35 Correct 5 ms 5400 KB Output is correct
36 Correct 5 ms 5272 KB Output is correct
37 Correct 4 ms 5332 KB Output is correct
38 Correct 3 ms 4564 KB Output is correct
39 Correct 4 ms 4652 KB Output is correct
40 Correct 7 ms 6548 KB Output is correct
41 Correct 3 ms 4564 KB Output is correct
42 Correct 7 ms 6560 KB Output is correct
43 Correct 7 ms 6560 KB Output is correct
44 Correct 11 ms 6484 KB Output is correct
45 Correct 3 ms 4180 KB Output is correct
46 Incorrect 8 ms 6612 KB Output isn't correct
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 5 ms 5276 KB Output is correct
5 Correct 5 ms 5328 KB Output is correct
6 Correct 5 ms 5332 KB Output is correct
7 Correct 6 ms 5404 KB Output is correct
8 Correct 2 ms 4248 KB Output is correct
9 Correct 2 ms 4240 KB Output is correct
10 Correct 3 ms 4180 KB Output is correct
11 Correct 6 ms 5332 KB Output is correct
12 Correct 5 ms 5276 KB Output is correct
13 Correct 2 ms 4180 KB Output is correct
14 Correct 5 ms 5324 KB Output is correct
15 Correct 2 ms 4240 KB Output is correct
16 Correct 5 ms 5332 KB Output is correct
17 Correct 2 ms 4240 KB Output is correct
18 Correct 6 ms 5332 KB Output is correct
19 Correct 2 ms 4244 KB Output is correct
20 Correct 4 ms 5152 KB Output is correct
21 Correct 4 ms 5076 KB Output is correct
22 Correct 2 ms 4180 KB Output is correct
23 Correct 6 ms 6100 KB Output is correct
24 Correct 2 ms 4252 KB Output is correct
25 Correct 6 ms 6100 KB Output is correct
26 Correct 6 ms 5844 KB Output is correct
27 Correct 8 ms 7252 KB Output is correct
28 Correct 6 ms 5844 KB Output is correct
29 Correct 6 ms 7324 KB Output is correct
30 Correct 6 ms 5460 KB Output is correct
31 Correct 7 ms 6356 KB Output is correct
32 Correct 6 ms 5408 KB Output is correct
33 Correct 7 ms 6432 KB Output is correct
34 Correct 6 ms 6484 KB Output is correct
35 Correct 5 ms 5400 KB Output is correct
36 Correct 5 ms 5272 KB Output is correct
37 Correct 4 ms 5332 KB Output is correct
38 Correct 3 ms 4564 KB Output is correct
39 Correct 4 ms 4652 KB Output is correct
40 Correct 7 ms 6548 KB Output is correct
41 Correct 3 ms 4564 KB Output is correct
42 Correct 7 ms 6560 KB Output is correct
43 Correct 7 ms 6560 KB Output is correct
44 Correct 2 ms 4180 KB Output is correct
45 Correct 131 ms 33724 KB Output is correct
46 Correct 57 ms 17368 KB Output is correct
47 Correct 128 ms 35408 KB Output is correct
48 Correct 137 ms 35332 KB Output is correct
49 Correct 41 ms 15944 KB Output is correct
50 Correct 116 ms 29660 KB Output is correct
51 Incorrect 127 ms 35440 KB Output isn't correct
52 Halted 0 ms 0 KB -