# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
239315 | 2020-06-15T11:20:26 Z | dsjong | Political Development (BOI17_politicaldevelopment) | C++14 | 38 ms | 2688 KB |
#include <bits/stdc++.h> using namespace std; int sz[100005]; bool good[2000]; vector<int>adj[100005]; map<pair<int, int>, int> mp; int main(){ int n, k; cin>>n>>k; for(int i=0;i<n;i++){ int d; cin>>d; for(int j=0;j<d;j++){ int x; cin>>x; adj[i].push_back(x); mp[{i, x}]=true; } sz[i]=d; } int ans=1; for(int t=0;t<n;t++){ int mini=INT_MAX, idx; for(int i=0;i<n;i++){ if(sz[i]<mini){ mini=sz[i]; idx=i; } } // cout<<idx<<endl; vector<int>v; for(int i:adj[idx]){ if(sz[i]<=n) v.push_back(i); } int m=v.size(); good[0]=true; for(int i=1;i<(1<<m);i++){ int lg=log2(i); int x=i-(1<<lg); if(good[x]){ bool b=true; for(int j=0;j<m;j++){ if((1<<j)&x) b&=mp[{v[j], v[lg]}]; } good[i]=b; } else good[i]=false; if(good[i]){ int cnt=0; for(int j=0;j<m;j++){ if((1<<j)&i){ cnt++; cout<<v[j]<<" "; } } cout<<idx<<endl; ans=max(ans, cnt+1); } } sz[idx]=INT_MAX; for(int i:adj[idx]) sz[i]--; } cout<<ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 2688 KB | Output is correct |
2 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |