Submission #472529

#TimeUsernameProblemLanguageResultExecution timeMemory
472529Blobo2_Blobo2Political Development (BOI17_politicaldevelopment)C++14
0 / 100
5 ms4172 KiB
/* 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]; unordered_set<int>st[50001]; vector<int>path; bool vis2[50001]; int mx[50001]; int root = 0; inline void dfs(int u){ if(path.size()+1 == now){ cout<<now<<endl; exit(0); } mx[root]= max(mx[root],(int)path.size()); mx[u]=max(mx[u],(int)path.size()); path.push_back(u); for(auto v:adj[u]){ bool bos_ana_zh2t=0; for(int i=0;i<path.size();i++)if(path[i] == v)bos_ana_zh2t = 1; if(bos_ana_zh2t)continue; if(!vis2[v]){ bool iwillgothere = 1; for(int i=0;i<path.size();i++){ if(st[path[i]].find(v) != st[path[i]].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[i].insert(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 i=0;i<n;i++)vis2[i]=0; } return 0; }

Compilation message (stderr)

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:31:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |     if(path.size()+1 == now){
      |        ~~~~~~~~~~~~~~^~~~~~
politicaldevelopment.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int i=0;i<path.size();i++)if(path[i] == v)bos_ana_zh2t = 1;
      |                     ~^~~~~~~~~~~~
politicaldevelopment.cpp:44:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             for(int i=0;i<path.size();i++){
      |                         ~^~~~~~~~~~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:56:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |     freopen("in.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...