This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define ll long long
//#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef pair<int, pii> ipii;
const int MAXN = 2e5+10;
const int INF = 1e9+10;
const int SQRT = 500;
int n, k;
int ans = 1;
int d[MAXN];
set <int> adj[MAXN];
class Compare {
public:
bool operator()(int a, int b){
return d[a] > d[b];
}
};
priority_queue <int, vector<int>, Compare> pq;
void solve(int nw){
int deg = adj[nw].size();
if(deg > 11){
return;
}
vector <int> node;
for(int i=0; i<(1<<deg); i++){//setiap bitmask
node.clear(); //reset
auto it = adj[nw].begin(); //idx 1
for(int j=0; j<deg; j++){
if(j!=0) it++;
if((i>>j) & 1){//masuk ke mask
node.pb(*it); //node neighbour
}
}
bool can = 1;
for(auto in : node){
for(auto nei : node){
if(in == nei) continue;
if(adj[in].find(nei) == adj[in].end()) can = 0;
}
}
if(can){
//cout << nw << ' ' << node.size() << "upd\n";
ans = max(ans, (int) node.size() + 1);
}
}
for(auto in : adj[nw]){
adj[in].erase(nw);
d[in]--;
}
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> n >> k;
for(int i=1; i<=n; i++){
cin >> d[i];
for(int j=1; j<=d[i]; j++){
int x; cin >> x; x++;
adj[i].insert(x);
}
pq.push(i);
}
while(!pq.empty()){
int nw = pq.top(); pq.pop();
solve(nw);
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |