Submission #246572

#TimeUsernameProblemLanguageResultExecution timeMemory
246572m3r8Political Development (BOI17_politicaldevelopment)C++14
4 / 100
3083 ms315512 KiB
#include <stdio.h> #include <vector> #include <algorithm> #include <set> #include <bitset> #include <utility> #include <queue> #define N 50100 #define ii std::pair<int,int> std::vector<int> adj[N]; int k; std::vector<std::bitset<N>> add(N); std::queue<int> que; std::vector<int> akt; int used[N]; int clq(int idx){ int erg = 0; for(int i = 0;i<(1<<akt.size());i++){ std::bitset<N> tmp = add[idx]; int cnt = 0; for(int j = 0;j<akt.size();j++){ if(i & (1<<j)){ cnt++; tmp &= add[akt[j]]; }; }; if(tmp.count() >= cnt+1){ erg = std::max(erg,cnt+1); }; }; return erg; }; int main(void){ int n; scanf("%d %d",&n,&k); int d; int x; int mx = 1; for(int i = 0;i<n;i++){ add[i][i] = 1; scanf("%d",&d); for(int j = 0;j<d;j++){ mx = 2; scanf("%d",&x); add[i][x] = 1; adj[i].push_back(x); }; }; for(int i = 0;i<n;i++){ if(adj[i].size() < k){ //printf("%d %d\n",i,adj[i].size()); used[i] = 1; que.push(i); }; }; while(que.size()){ int ak = que.front();que.pop(); // printf("%d\n",ak); akt.clear(); used[ak] = 2; for(auto i: adj[ak]){ if(used[i] != 2){ akt.push_back(i); }; }; mx = std::max(mx,clq(ak)); for(auto i: adj[ak]){ if(!used[i]){ add[i][ak] = 0; if(add[i].count() < k){ used[i] = 1; que.push(i); }; }; }; }; printf("%d\n",mx); return 0; };

Compilation message (stderr)

politicaldevelopment.cpp: In function 'int clq(int)':
politicaldevelopment.cpp:26:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int j = 0;j<akt.size();j++){
                   ~^~~~~~~~~~~
politicaldevelopment.cpp:32:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(tmp.count() >= cnt+1){
        ~~~~~~~~~~~~^~~~~~~~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:56:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(adj[i].size() < k){
        ~~~~~~~~~~~~~~^~~
politicaldevelopment.cpp:76:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(add[i].count() < k){
            ~~~~~~~~~~~~~~~^~~
politicaldevelopment.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&n,&k);
   ~~~~~^~~~~~~~~~~~~~~
politicaldevelopment.cpp:47:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&d);
     ~~~~~^~~~~~~~~
politicaldevelopment.cpp:50:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d",&x);
       ~~~~~^~~~~~~~~
#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...