Submission #803042

#TimeUsernameProblemLanguageResultExecution timeMemory
803042AmirElarbiPolitical Development (BOI17_politicaldevelopment)C++14
100 / 100
1058 ms310348 KiB
#include<bits/stdc++.h> typedef long long ll; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pbds tree<pair<ll, ll>, null_type, less<pair<ll,ll>>,rb_tree_tag, tree_order_statistics_node_update> using namespace __gnu_pbds; #define speed ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; ////////////////////Only Clear Code////////////////////////// void usaco_problem(){ freopen("milkvisits.in", "r", stdin); freopen("milkvisits.out", "w", stdout); } void init(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // ONLINE_JUDGE } const int mx = 5e4+5; const int mxnd = mx*33; const int LOG = 25; const ll inf = 1e18; const ll mod = 1e8; vector<int> graph[mx]; int ans = 0; vector<int> cur; bool done[mx]; int n; bitset<50005> bg[mx]; void solve(int k, bitset<50005> bs){ if(ans == 10)return; ans = max(ans, k); if(k == 9){ if(bs != 0) ans = 10; return; } ans = max(ans, k); if(k == 0){ for(int i = 0; i < n;i++){ cur.push_back(i); done[i] = 1; solve(k+1, bg[i]); done[i] = 0; cur.pop_back(); } return; } bitset<50005> now = bs; while(now != 0){ long unsigned int to = now._Find_first(); now[to] = 0; solve(k+1, now & bg[to]); if(ans == 10) return; } /* for(int adj : graph[cur[0]]){ if(done[adj])continue; bool take = 1; for(int x : cur){ if(mp[x][adj] == 0)take = 0; } if(take){ cur.push_back(adj); done[adj] = 1; solve(k+1); done[adj] = 0; cur.pop_back(); } }*/ } void run_case(){ int k;cin >> n >> k; for(int i = 0; i < n;i++){ int c;cin >> c; while(c--){ int x;cin >> x; //graph[i].push_back(x); bg[i][x] = 1; } } ans = 0; solve(0,0); cout << ans << endl; } int main(){ speed; int t = 1; //cin >> t; while(t--){ run_case(); } } /* NEVER GIVE UP! DOING SMTHNG IS BETTER THAN DOING NTHNG!!! Your Guide when stuck: - Continue keyword only after reading the whole input - Don't use memset with testcases - Check for corner cases(n=1, n=0) - Check where you declare n(Be careful of declaring it globally and in main) */

Compilation message (stderr)

politicaldevelopment.cpp: In function 'void usaco_problem()':
politicaldevelopment.cpp:11:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     freopen("milkvisits.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:12:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     freopen("milkvisits.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp: In function 'void init()':
politicaldevelopment.cpp:18:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 | freopen("input.txt", "r", stdin);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:20:8: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 | freopen("output.txt", "w", stdout);
      | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...