Submission #311271

# Submission time Handle Problem Language Result Execution time Memory
311271 2020-10-09T19:50:58 Z Vladth11 Political Development (BOI17_politicaldevelopment) C++14
0 / 100
10 ms 5760 KB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debug_with_space(x) cerr << #x << " " << x << " "
 
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <ll, pii> muchie;
 
const ll NMAX = 100005;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 101;
 
set <int> v[NMAX],st;
int maxim = 0,k;
int deg[NMAX];
set <pii> pq;
void afiseaza(int x){
    for(auto i : v[x])
        debug_with_space(i);
    cerr << "\n";
}
 
void clique(int i) {
    int nrbits = v[i].size();
    // debug(i);
  if(nrbits > 10)
    return;
    for(int mask = 1; mask < (1 << nrbits); mask++) {
        int cnt = 1;int bb = __builtin_popcount(mask);
        if(bb + 1 > k || bb + 1 < maxim)
            continue;
        int j = 0,cc = 0;
        st.clear();
        for(auto y : v[i]){
            if(mask & (1 << j))
                st.insert(y);
            j++;
        }
        j = 0;
        for(auto y : st){
            for(auto x : st){
                if(x != y && v[x].find(y) == v[x].end() && v[y].find(x) == v[y].end())
                    cnt = 0;
            }
        }
 
         //  debug_with_space(mask);
         //debug(cnt);
        if(cnt == 1)
            maxim = max(maxim, bb + 1);
    }
    //debug(maxim);
    for(auto x : v[i]){
        //if(pq.size())
        pq.erase({v[x].size(),x});
        v[x].erase(i);
        pq.insert({v[x].size(),x});
    }
    //debug(maxim);
}
 
struct cmp{
    bool operator()(int x, int y){
        return v[x].size() < v[y].size();
    }
};
int main() {
    // ifstream cin("catsfood.in");
    // ofstream cout("catsfood.out");
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, i, d;
    cin >> n >> k;
    for(i = 1; i <= n; i++) {
        int d;
        cin >> d;
        while(d--) {
            int x;
            cin >> x;
            v[i].insert(x + 1);
        }
    }
 
    for(i = 1; i <= n; i++) {
        pq.insert({v[i].size(),i});
    }
    while(!pq.empty()){
        int top = (*pq.begin()).second;
        pq.erase(pq.begin());
        clique(top);
    }
    cout << maxim;
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'void clique(int)':
politicaldevelopment.cpp:28:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   28 |   if(nrbits > 10)
      |   ^~
politicaldevelopment.cpp:30:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   30 |     for(int mask = 1; mask < (1 << nrbits); mask++) {
      |     ^~~
politicaldevelopment.cpp:34:19: warning: unused variable 'cc' [-Wunused-variable]
   34 |         int j = 0,cc = 0;
      |                   ^~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:75:15: warning: unused variable 'd' [-Wunused-variable]
   75 |     int n, i, d;
      |               ^
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 9 ms 5760 KB Output is correct
4 Correct 9 ms 5760 KB Output is correct
5 Correct 10 ms 5760 KB Output is correct
6 Correct 9 ms 5760 KB Output is correct
7 Correct 9 ms 5760 KB Output is correct
8 Incorrect 5 ms 5376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 9 ms 5760 KB Output is correct
4 Correct 9 ms 5760 KB Output is correct
5 Correct 10 ms 5760 KB Output is correct
6 Correct 9 ms 5760 KB Output is correct
7 Correct 9 ms 5760 KB Output is correct
8 Incorrect 5 ms 5376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 5376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 9 ms 5760 KB Output is correct
4 Correct 9 ms 5760 KB Output is correct
5 Correct 10 ms 5760 KB Output is correct
6 Correct 9 ms 5760 KB Output is correct
7 Correct 9 ms 5760 KB Output is correct
8 Incorrect 5 ms 5376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4992 KB Output is correct
2 Correct 3 ms 4992 KB Output is correct
3 Correct 9 ms 5760 KB Output is correct
4 Correct 9 ms 5760 KB Output is correct
5 Correct 10 ms 5760 KB Output is correct
6 Correct 9 ms 5760 KB Output is correct
7 Correct 9 ms 5760 KB Output is correct
8 Incorrect 5 ms 5376 KB Output isn't correct
9 Halted 0 ms 0 KB -