Submission #948333

#TimeUsernameProblemLanguageResultExecution timeMemory
948333steveonalexPolitical Development (BOI17_politicaldevelopment)C++14
100 / 100
491 ms336724 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define MASK(i) (1LL << (i)) #define GETBIT(mask, i) (((mask) >> (i)) & 1) #define ALL(v) (v).begin(), (v).end() ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll LASTBIT(ll mask){return (mask) & (-mask);} int pop_cnt(ll mask){return __builtin_popcountll(mask);} int ctz(ll mask){return __builtin_ctzll(mask);} int logOf(ll mask){return 63 - __builtin_clzll(mask);} mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);} template <class T1, class T2> bool maximize(T1 &a, T2 b){ if (a < b) {a = b; return true;} return false; } template <class T1, class T2> bool minimize(T1 &a, T2 b){ if (a > b) {a = b; return true;} return false; } template <class T> void printArr(T container, char separator = ' ', char finish = '\n'){ for(auto item: container) cout << item << separator; cout << finish; } template <class T> void remove_dup(vector<T> &a){ sort(ALL(a)); a.resize(unique(ALL(a)) - a.begin()); } const long N = 5e4 + 69; long n, k; set<long> graph[N]; namespace Sub5{ bitset<N> g[N]; long solve(){ for(long i = 0; i<n; ++i) for(long j: graph[i]) g[i][j] = 1; long ans= 1; set<pair<long, long>> S; for(long i = 0; i<n; ++i) S.insert({graph[i].size(), i}); while(S.size()){ pair<long,long> u = *S.begin(); S.erase(u); long i = u.second; for(long j: graph[i]){ S.erase({graph[j].size(), j}); graph[j].erase(i); S.insert({graph[j].size(), j}); } vector<long> dick(ALL(graph[i])); for(long j = 0; j<MASK(dick.size()); ++j){ vector<long> tits; tits.reserve(dick.size() + 1); tits.push_back(i); for(long k = 0; k<dick.size(); ++k) if (GETBIT(j, k)) tits.push_back(dick[k]); bool check = true; for(long x = 0; x < tits.size(); ++x) for(long y = x+1; y<tits.size(); ++y) if (!g[tits[x]][tits[y]]) check = false; if (check) maximize(ans, tits.size()); } } return ans; } } int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> k; for(long i= 0; i<n; ++i){ long d; cin >> d; while(d--){ long j; cin >> j; graph[i].insert(j); } } cout << Sub5::solve() << "\n"; return 0; }

Compilation message (stderr)

politicaldevelopment.cpp: In function 'long int Sub5::solve()':
politicaldevelopment.cpp:77:34: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |                 for(long k = 0; k<dick.size(); ++k) if (GETBIT(j, k)) tits.push_back(dick[k]);
      |                                 ~^~~~~~~~~~~~
politicaldevelopment.cpp:79:35: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |                 for(long x = 0; x < tits.size(); ++x)
      |                                 ~~^~~~~~~~~~~~~
politicaldevelopment.cpp:80:36: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |                 for(long y = x+1; y<tits.size(); ++y) if (!g[tits[x]][tits[y]]) check = false;
      |                                   ~^~~~~~~~~~~~
politicaldevelopment.cpp: In instantiation of 'bool maximize(T1&, T2) [with T1 = long int; T2 = long unsigned int]':
politicaldevelopment.cpp:81:53:   required from here
politicaldevelopment.cpp:25:15: warning: comparison of integer expressions of different signedness: 'long int' and 'long unsigned int' [-Wsign-compare]
   25 |         if (a < b) {a = b; return true;}
      |             ~~^~~
#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...