Submission #472518

# Submission time Handle Problem Language Result Execution time Memory
472518 2021-09-13T16:50:23 Z Blobo2_Blobo2 Political Development (BOI17_politicaldevelopment) C++14
16 / 100
3000 ms 26792 KB
/*
Editor: Abdelrahman Hossam
Nickname: Blobo2_Blobo2
IOI next year isA :)
*/
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")

#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define gen(arr,n,nxt)  generate(arr,arr+n,nxt)
#define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0);
#define EPS 0.00000001

const int mo=1e9+7,INF=1e18;
int nxt(){int x;cin>>x;return x;}
int now=-1;
vector<int>adj[50001];
set<pair<int,int>>st;
bool vis[50001];
vector<int>path;
bool vis2[50001];
int mx[50001];
int root = 0;
inline void dfs(int u){
    mx[root]= max(mx[root],(int)path.size());
    mx[u]=max(mx[u],(int)path.size());
    if(path.size()+1 == now){
        cout<<now<<endl;
        exit(0);
    }
    vis[u] = 1;
    path.push_back(u);
    for(auto v:adj[u]){
        if(!vis[v]&&!vis2[v]){
            bool iwillgothere = 1;
            for(int i=0;i<path.size();i++){
                if(st.find({path[i],v}) != st.end());
                else iwillgothere&=0;
            }
            if(iwillgothere)
                dfs(v);
        }
    }
    path.pop_back();
}
signed main(){
    Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty
    //freopen("in.txt","r",stdin);
    int n=nxt(),k=nxt();
    for(int i=0;i<n;i++){
        int sz = nxt();
        for(int j=0;j<sz;j++){
            int x=nxt();
            adj[i].push_back(x);
            st.insert({i,x});
        }
    }
    int ans = -1;
    for(ans = k;ans>=1;ans--){
        now = ans;
        for(int i =0;i<n;i++){
            if(mx[i]>=ans){
                cout<<ans<<endl;
                return 0;
            }
            root = i;
            vis2[i]=1;
            dfs(i);
            for(int j=i;j<n;j++)vis[j] = 0;
        }
        for(int i=0;i<n;i++)vis2[i]=0;
    }
    return 0;
}

Compilation message

politicaldevelopment.cpp:21:24: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   21 | const int mo=1e9+7,INF=1e18;
      |                        ^~~~
politicaldevelopment.cpp: In function 'void dfs(int)':
politicaldevelopment.cpp:34:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     if(path.size()+1 == now){
      |        ~~~~~~~~~~~~~~^~~~~~
politicaldevelopment.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             for(int i=0;i<path.size();i++){
      |                         ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1484 KB Output is correct
2 Correct 1 ms 1484 KB Output is correct
3 Correct 5 ms 2124 KB Output is correct
4 Correct 5 ms 2124 KB Output is correct
5 Correct 5 ms 2124 KB Output is correct
6 Correct 5 ms 2124 KB Output is correct
7 Correct 5 ms 2172 KB Output is correct
8 Correct 2 ms 1484 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 2 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1484 KB Output is correct
2 Correct 1 ms 1484 KB Output is correct
3 Correct 5 ms 2124 KB Output is correct
4 Correct 5 ms 2124 KB Output is correct
5 Correct 5 ms 2124 KB Output is correct
6 Correct 5 ms 2124 KB Output is correct
7 Correct 5 ms 2172 KB Output is correct
8 Correct 2 ms 1484 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 2 ms 1484 KB Output is correct
11 Correct 5 ms 2068 KB Output is correct
12 Correct 973 ms 2152 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
14 Correct 1704 ms 2272 KB Output is correct
15 Correct 1 ms 1484 KB Output is correct
16 Correct 21 ms 2136 KB Output is correct
17 Correct 1 ms 1484 KB Output is correct
18 Correct 21 ms 2184 KB Output is correct
19 Correct 3 ms 1484 KB Output is correct
20 Correct 4 ms 1868 KB Output is correct
21 Correct 3 ms 1868 KB Output is correct
22 Correct 2 ms 1484 KB Output is correct
23 Correct 6 ms 2252 KB Output is correct
24 Correct 2 ms 1484 KB Output is correct
25 Correct 8 ms 2252 KB Output is correct
26 Correct 10 ms 2124 KB Output is correct
27 Correct 7 ms 2124 KB Output is correct
28 Correct 9 ms 2212 KB Output is correct
29 Correct 7 ms 2124 KB Output is correct
30 Correct 239 ms 2312 KB Output is correct
31 Correct 10 ms 2252 KB Output is correct
32 Correct 169 ms 2324 KB Output is correct
33 Correct 9 ms 2200 KB Output is correct
34 Correct 9 ms 2252 KB Output is correct
35 Correct 5 ms 1868 KB Output is correct
36 Correct 5 ms 1868 KB Output is correct
37 Correct 5 ms 1848 KB Output is correct
38 Correct 7 ms 1740 KB Output is correct
39 Correct 7 ms 1740 KB Output is correct
40 Correct 8 ms 2636 KB Output is correct
41 Correct 8 ms 1740 KB Output is correct
42 Correct 8 ms 2636 KB Output is correct
43 Correct 8 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1484 KB Output is correct
2 Correct 1 ms 1484 KB Output is correct
3 Correct 1 ms 1484 KB Output is correct
4 Correct 1 ms 1484 KB Output is correct
5 Correct 1 ms 1484 KB Output is correct
6 Correct 1 ms 1484 KB Output is correct
7 Correct 1 ms 1484 KB Output is correct
8 Correct 2 ms 1484 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Execution timed out 3066 ms 26792 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1484 KB Output is correct
2 Correct 1 ms 1484 KB Output is correct
3 Correct 5 ms 2124 KB Output is correct
4 Correct 5 ms 2124 KB Output is correct
5 Correct 5 ms 2124 KB Output is correct
6 Correct 5 ms 2124 KB Output is correct
7 Correct 5 ms 2172 KB Output is correct
8 Correct 2 ms 1484 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 2 ms 1484 KB Output is correct
11 Correct 5 ms 2068 KB Output is correct
12 Correct 973 ms 2152 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
14 Correct 1704 ms 2272 KB Output is correct
15 Correct 1 ms 1484 KB Output is correct
16 Correct 21 ms 2136 KB Output is correct
17 Correct 1 ms 1484 KB Output is correct
18 Correct 21 ms 2184 KB Output is correct
19 Correct 3 ms 1484 KB Output is correct
20 Correct 4 ms 1868 KB Output is correct
21 Correct 3 ms 1868 KB Output is correct
22 Correct 2 ms 1484 KB Output is correct
23 Correct 6 ms 2252 KB Output is correct
24 Correct 2 ms 1484 KB Output is correct
25 Correct 8 ms 2252 KB Output is correct
26 Correct 10 ms 2124 KB Output is correct
27 Correct 7 ms 2124 KB Output is correct
28 Correct 9 ms 2212 KB Output is correct
29 Correct 7 ms 2124 KB Output is correct
30 Correct 239 ms 2312 KB Output is correct
31 Correct 10 ms 2252 KB Output is correct
32 Correct 169 ms 2324 KB Output is correct
33 Correct 9 ms 2200 KB Output is correct
34 Correct 9 ms 2252 KB Output is correct
35 Correct 5 ms 1868 KB Output is correct
36 Correct 5 ms 1868 KB Output is correct
37 Correct 5 ms 1848 KB Output is correct
38 Correct 7 ms 1740 KB Output is correct
39 Correct 7 ms 1740 KB Output is correct
40 Correct 8 ms 2636 KB Output is correct
41 Correct 8 ms 1740 KB Output is correct
42 Correct 8 ms 2636 KB Output is correct
43 Correct 8 ms 2636 KB Output is correct
44 Correct 15 ms 3532 KB Output is correct
45 Correct 1 ms 1484 KB Output is correct
46 Correct 8 ms 2544 KB Output is correct
47 Correct 52 ms 3668 KB Output is correct
48 Correct 17 ms 2644 KB Output is correct
49 Correct 49 ms 3632 KB Output is correct
50 Correct 114 ms 3644 KB Output is correct
51 Correct 30 ms 5752 KB Output is correct
52 Correct 5 ms 2124 KB Output is correct
53 Execution timed out 3074 ms 6328 KB Time limit exceeded
54 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1484 KB Output is correct
2 Correct 1 ms 1484 KB Output is correct
3 Correct 5 ms 2124 KB Output is correct
4 Correct 5 ms 2124 KB Output is correct
5 Correct 5 ms 2124 KB Output is correct
6 Correct 5 ms 2124 KB Output is correct
7 Correct 5 ms 2172 KB Output is correct
8 Correct 2 ms 1484 KB Output is correct
9 Correct 1 ms 1484 KB Output is correct
10 Correct 2 ms 1484 KB Output is correct
11 Correct 5 ms 2068 KB Output is correct
12 Correct 973 ms 2152 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
14 Correct 1704 ms 2272 KB Output is correct
15 Correct 1 ms 1484 KB Output is correct
16 Correct 21 ms 2136 KB Output is correct
17 Correct 1 ms 1484 KB Output is correct
18 Correct 21 ms 2184 KB Output is correct
19 Correct 3 ms 1484 KB Output is correct
20 Correct 4 ms 1868 KB Output is correct
21 Correct 3 ms 1868 KB Output is correct
22 Correct 2 ms 1484 KB Output is correct
23 Correct 6 ms 2252 KB Output is correct
24 Correct 2 ms 1484 KB Output is correct
25 Correct 8 ms 2252 KB Output is correct
26 Correct 10 ms 2124 KB Output is correct
27 Correct 7 ms 2124 KB Output is correct
28 Correct 9 ms 2212 KB Output is correct
29 Correct 7 ms 2124 KB Output is correct
30 Correct 239 ms 2312 KB Output is correct
31 Correct 10 ms 2252 KB Output is correct
32 Correct 169 ms 2324 KB Output is correct
33 Correct 9 ms 2200 KB Output is correct
34 Correct 9 ms 2252 KB Output is correct
35 Correct 5 ms 1868 KB Output is correct
36 Correct 5 ms 1868 KB Output is correct
37 Correct 5 ms 1848 KB Output is correct
38 Correct 7 ms 1740 KB Output is correct
39 Correct 7 ms 1740 KB Output is correct
40 Correct 8 ms 2636 KB Output is correct
41 Correct 8 ms 1740 KB Output is correct
42 Correct 8 ms 2636 KB Output is correct
43 Correct 8 ms 2636 KB Output is correct
44 Correct 1 ms 1484 KB Output is correct
45 Correct 197 ms 18056 KB Output is correct
46 Execution timed out 3052 ms 10428 KB Time limit exceeded
47 Halted 0 ms 0 KB -