Submission #311248

# Submission time Handle Problem Language Result Execution time Memory
311248 2020-10-09T18:51:55 Z Vladth11 Political Development (BOI17_politicaldevelopment) C++14
0 / 100
5 ms 5376 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];
int st[NMAX];
int maxim = 0;
int deg[NMAX];

void clique(int i) {
    int nrbits = v[i].size();
    // debug(i);
    for(int mask = 1; mask < (1 << nrbits); mask++) {
        int cnt = 0;
        int j = 0,cc = 0;
        for(auto y : v[i]) {
            if(mask & (1 << j)) {
                //debug(y);
                for(auto x : v[y]) {
                    //debug(x);
                    if(v[i].find(x) != v[i].end())
                        cnt++;
                }
            }
            j++;
        }
        int bb = __builtin_popcount(mask);
        //   debug_with_space(mask);
        // debug(cnt);
        if(cnt == bb * bb)
            maxim = max(maxim, bb);
    }

}

struct cmp{
    bool operator()(int x, int y){
        return v[x].size() < v[y].size();
    }
};
priority_queue <int, vector <int>, cmp > pq;
int main() {
    // ifstream cin("catsfood.in");
    // ofstream cout("catsfood.out");
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, i, d;
    cin >> n >> k;
    for(i = 1; i <= n; i++) {
        int d;
        cin >> d;
        v[i].insert(i);
        while(d--) {
            int x;
            cin >> x;
            v[i].insert(x + 1);
            v[x + 1].insert(i);
        }
    }
    for(i = 1; i <= n; i++) {
        pq.push(i);
    }
    while(!pq.empty()){
        int top = pq.top();
        pq.pop();
        clique(top);
    }
    cout << maxim;
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'void clique(int)':
politicaldevelopment.cpp:25:19: warning: unused variable 'cc' [-Wunused-variable]
   25 |         int j = 0,cc = 0;
      |                   ^~
politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:58:18: warning: unused variable 'd' [-Wunused-variable]
   58 |     int n, k, i, d;
      |                  ^
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 5376 KB Output is correct
2 Incorrect 4 ms 5092 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4992 KB Output isn't correct
2 Halted 0 ms 0 KB -