Submission #457999

# Submission time Handle Problem Language Result Execution time Memory
457999 2021-08-07T17:54:24 Z julian33 Political Development (BOI17_politicaldevelopment) C++14
77 / 100
3000 ms 24176 KB
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
    cerr<<vars<<" = ";
    string delim="";
    (...,(cerr<<delim<<values,delim=", "));
    cerr<<"\n";
}
#else
#define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {}
#endif

#define pb push_back
#define sz(x) (int)(x.size())
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> inline void maxa(T& a,T b){a=max(a,b);}
template<typename T> inline void mina(T& a,T b){a=min(a,b);} 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mxN=5e4+5; //make sure this is right
const int mod=1e9+7;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_set<int,custom_hash> graph[mxN];
vector<int> cur;
int n,k;

bool dfs(int s){
    if(!s)
        return 1;
    int at=cur.back();
    for(int i:graph[at]){
        if(sz(graph[i])<s-1)
            continue;
        int bad=0;
        for(int &j:cur){
            if(!graph[j].count(i)){
                bad=1;
                break;
            }
        }
        if(bad)
            continue;
        cur.pb(i);
        if(dfs(s-1))
            return 1;
        cur.pop_back();
    }
    return 0;
}

bool check(int s){
    for(int i=0;i<n;i++){
        if(sz(graph[i])<s-1)
            continue;
        cur={i};
        if(dfs(s-1))
            return 1;
    }
    return 0;
}

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    #ifdef LOCAL
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    cin>>n>>k;
    for(int i=0;i<n;i++){
        int d; cin>>d;
        while(d--){
            int x; cin>>x;
            graph[i].insert(x);
        }
    }
    for(int i=0;i<n;i++){
        vector<int> rem;
        for(int j:graph[i]){
            if(!graph[j].count(i) || j<=i)
                rem.pb(j);
        }
        for(int &j:rem)
            graph[i].erase(j);
    }
    int l=1; int r=k;
    int ans=1;
    while(l<=r){
        int mid=(l+r)>>1;
        if(check(mid)){
            ans=mid; l=mid+1;
        } else{
            r=mid-1;
        }
    }
    cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3020 KB Output is correct
2 Correct 2 ms 3020 KB Output is correct
3 Correct 8 ms 3916 KB Output is correct
4 Correct 6 ms 3972 KB Output is correct
5 Correct 6 ms 3916 KB Output is correct
6 Correct 7 ms 3916 KB Output is correct
7 Correct 7 ms 3916 KB Output is correct
8 Correct 2 ms 3020 KB Output is correct
9 Correct 2 ms 3020 KB Output is correct
10 Correct 2 ms 3020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3020 KB Output is correct
2 Correct 2 ms 3020 KB Output is correct
3 Correct 8 ms 3916 KB Output is correct
4 Correct 6 ms 3972 KB Output is correct
5 Correct 6 ms 3916 KB Output is correct
6 Correct 7 ms 3916 KB Output is correct
7 Correct 7 ms 3916 KB Output is correct
8 Correct 2 ms 3020 KB Output is correct
9 Correct 2 ms 3020 KB Output is correct
10 Correct 2 ms 3020 KB Output is correct
11 Correct 7 ms 3916 KB Output is correct
12 Correct 7 ms 3916 KB Output is correct
13 Correct 2 ms 3020 KB Output is correct
14 Correct 6 ms 3916 KB Output is correct
15 Correct 2 ms 3020 KB Output is correct
16 Correct 7 ms 3960 KB Output is correct
17 Correct 2 ms 3020 KB Output is correct
18 Correct 7 ms 3916 KB Output is correct
19 Correct 2 ms 3020 KB Output is correct
20 Correct 5 ms 3660 KB Output is correct
21 Correct 5 ms 3660 KB Output is correct
22 Correct 3 ms 3020 KB Output is correct
23 Correct 8 ms 3900 KB Output is correct
24 Correct 3 ms 3020 KB Output is correct
25 Correct 9 ms 4052 KB Output is correct
26 Correct 8 ms 3952 KB Output is correct
27 Correct 8 ms 3916 KB Output is correct
28 Correct 9 ms 3916 KB Output is correct
29 Correct 6 ms 3920 KB Output is correct
30 Correct 19 ms 4080 KB Output is correct
31 Correct 8 ms 3972 KB Output is correct
32 Correct 20 ms 4068 KB Output is correct
33 Correct 8 ms 3916 KB Output is correct
34 Correct 8 ms 3916 KB Output is correct
35 Correct 7 ms 3532 KB Output is correct
36 Correct 5 ms 3532 KB Output is correct
37 Correct 5 ms 3532 KB Output is correct
38 Correct 4 ms 3276 KB Output is correct
39 Correct 4 ms 3276 KB Output is correct
40 Correct 10 ms 4208 KB Output is correct
41 Correct 5 ms 3380 KB Output is correct
42 Correct 10 ms 4196 KB Output is correct
43 Correct 10 ms 4232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3020 KB Output is correct
2 Correct 2 ms 3020 KB Output is correct
3 Correct 2 ms 3020 KB Output is correct
4 Correct 2 ms 3020 KB Output is correct
5 Correct 2 ms 3032 KB Output is correct
6 Correct 2 ms 3020 KB Output is correct
7 Correct 3 ms 3020 KB Output is correct
8 Correct 2 ms 3020 KB Output is correct
9 Correct 2 ms 3020 KB Output is correct
10 Correct 2 ms 3020 KB Output is correct
11 Correct 301 ms 22616 KB Output is correct
12 Correct 2 ms 3020 KB Output is correct
13 Correct 236 ms 22604 KB Output is correct
14 Correct 2 ms 3020 KB Output is correct
15 Correct 308 ms 22704 KB Output is correct
16 Correct 249 ms 22708 KB Output is correct
17 Correct 239 ms 22604 KB Output is correct
18 Correct 246 ms 22608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3020 KB Output is correct
2 Correct 2 ms 3020 KB Output is correct
3 Correct 8 ms 3916 KB Output is correct
4 Correct 6 ms 3972 KB Output is correct
5 Correct 6 ms 3916 KB Output is correct
6 Correct 7 ms 3916 KB Output is correct
7 Correct 7 ms 3916 KB Output is correct
8 Correct 2 ms 3020 KB Output is correct
9 Correct 2 ms 3020 KB Output is correct
10 Correct 2 ms 3020 KB Output is correct
11 Correct 7 ms 3916 KB Output is correct
12 Correct 7 ms 3916 KB Output is correct
13 Correct 2 ms 3020 KB Output is correct
14 Correct 6 ms 3916 KB Output is correct
15 Correct 2 ms 3020 KB Output is correct
16 Correct 7 ms 3960 KB Output is correct
17 Correct 2 ms 3020 KB Output is correct
18 Correct 7 ms 3916 KB Output is correct
19 Correct 2 ms 3020 KB Output is correct
20 Correct 5 ms 3660 KB Output is correct
21 Correct 5 ms 3660 KB Output is correct
22 Correct 3 ms 3020 KB Output is correct
23 Correct 8 ms 3900 KB Output is correct
24 Correct 3 ms 3020 KB Output is correct
25 Correct 9 ms 4052 KB Output is correct
26 Correct 8 ms 3952 KB Output is correct
27 Correct 8 ms 3916 KB Output is correct
28 Correct 9 ms 3916 KB Output is correct
29 Correct 6 ms 3920 KB Output is correct
30 Correct 19 ms 4080 KB Output is correct
31 Correct 8 ms 3972 KB Output is correct
32 Correct 20 ms 4068 KB Output is correct
33 Correct 8 ms 3916 KB Output is correct
34 Correct 8 ms 3916 KB Output is correct
35 Correct 7 ms 3532 KB Output is correct
36 Correct 5 ms 3532 KB Output is correct
37 Correct 5 ms 3532 KB Output is correct
38 Correct 4 ms 3276 KB Output is correct
39 Correct 4 ms 3276 KB Output is correct
40 Correct 10 ms 4208 KB Output is correct
41 Correct 5 ms 3380 KB Output is correct
42 Correct 10 ms 4196 KB Output is correct
43 Correct 10 ms 4232 KB Output is correct
44 Correct 15 ms 4856 KB Output is correct
45 Correct 2 ms 3020 KB Output is correct
46 Correct 10 ms 4172 KB Output is correct
47 Correct 20 ms 4812 KB Output is correct
48 Correct 12 ms 4172 KB Output is correct
49 Correct 24 ms 4928 KB Output is correct
50 Correct 21 ms 4812 KB Output is correct
51 Correct 35 ms 6408 KB Output is correct
52 Correct 6 ms 3916 KB Output is correct
53 Correct 1969 ms 6816 KB Output is correct
54 Correct 41 ms 6860 KB Output is correct
55 Correct 7 ms 3916 KB Output is correct
56 Correct 6 ms 3916 KB Output is correct
57 Correct 2 ms 3020 KB Output is correct
58 Correct 2105 ms 6880 KB Output is correct
59 Correct 9 ms 4172 KB Output is correct
60 Correct 8 ms 3976 KB Output is correct
61 Correct 10 ms 4204 KB Output is correct
62 Correct 10 ms 4172 KB Output is correct
63 Correct 18 ms 4856 KB Output is correct
64 Correct 14 ms 4704 KB Output is correct
65 Correct 9 ms 4044 KB Output is correct
66 Correct 10 ms 4172 KB Output is correct
67 Correct 21 ms 5196 KB Output is correct
68 Correct 16 ms 4644 KB Output is correct
69 Correct 9 ms 4044 KB Output is correct
70 Correct 17 ms 4752 KB Output is correct
71 Correct 21 ms 5196 KB Output is correct
72 Correct 20 ms 5132 KB Output is correct
73 Correct 8 ms 3916 KB Output is correct
74 Correct 16 ms 4684 KB Output is correct
75 Correct 22 ms 5208 KB Output is correct
76 Correct 15 ms 4468 KB Output is correct
77 Correct 33 ms 5500 KB Output is correct
78 Correct 7 ms 3916 KB Output is correct
79 Correct 16 ms 4280 KB Output is correct
80 Correct 22 ms 4428 KB Output is correct
81 Correct 33 ms 5432 KB Output is correct
82 Correct 4 ms 3328 KB Output is correct
83 Correct 17 ms 4172 KB Output is correct
84 Correct 20 ms 5016 KB Output is correct
85 Correct 6 ms 3276 KB Output is correct
86 Correct 18 ms 4940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3020 KB Output is correct
2 Correct 2 ms 3020 KB Output is correct
3 Correct 8 ms 3916 KB Output is correct
4 Correct 6 ms 3972 KB Output is correct
5 Correct 6 ms 3916 KB Output is correct
6 Correct 7 ms 3916 KB Output is correct
7 Correct 7 ms 3916 KB Output is correct
8 Correct 2 ms 3020 KB Output is correct
9 Correct 2 ms 3020 KB Output is correct
10 Correct 2 ms 3020 KB Output is correct
11 Correct 7 ms 3916 KB Output is correct
12 Correct 7 ms 3916 KB Output is correct
13 Correct 2 ms 3020 KB Output is correct
14 Correct 6 ms 3916 KB Output is correct
15 Correct 2 ms 3020 KB Output is correct
16 Correct 7 ms 3960 KB Output is correct
17 Correct 2 ms 3020 KB Output is correct
18 Correct 7 ms 3916 KB Output is correct
19 Correct 2 ms 3020 KB Output is correct
20 Correct 5 ms 3660 KB Output is correct
21 Correct 5 ms 3660 KB Output is correct
22 Correct 3 ms 3020 KB Output is correct
23 Correct 8 ms 3900 KB Output is correct
24 Correct 3 ms 3020 KB Output is correct
25 Correct 9 ms 4052 KB Output is correct
26 Correct 8 ms 3952 KB Output is correct
27 Correct 8 ms 3916 KB Output is correct
28 Correct 9 ms 3916 KB Output is correct
29 Correct 6 ms 3920 KB Output is correct
30 Correct 19 ms 4080 KB Output is correct
31 Correct 8 ms 3972 KB Output is correct
32 Correct 20 ms 4068 KB Output is correct
33 Correct 8 ms 3916 KB Output is correct
34 Correct 8 ms 3916 KB Output is correct
35 Correct 7 ms 3532 KB Output is correct
36 Correct 5 ms 3532 KB Output is correct
37 Correct 5 ms 3532 KB Output is correct
38 Correct 4 ms 3276 KB Output is correct
39 Correct 4 ms 3276 KB Output is correct
40 Correct 10 ms 4208 KB Output is correct
41 Correct 5 ms 3380 KB Output is correct
42 Correct 10 ms 4196 KB Output is correct
43 Correct 10 ms 4232 KB Output is correct
44 Correct 2 ms 3020 KB Output is correct
45 Correct 165 ms 18172 KB Output is correct
46 Correct 105 ms 13460 KB Output is correct
47 Correct 177 ms 18332 KB Output is correct
48 Correct 160 ms 18188 KB Output is correct
49 Correct 59 ms 12548 KB Output is correct
50 Execution timed out 3077 ms 24176 KB Time limit exceeded
51 Halted 0 ms 0 KB -