답안 #239312

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
239312 2020-06-15T11:07:02 Z dsjong Political Development (BOI17_politicaldevelopment) C++14
0 / 100
61 ms 3584 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=0;
    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);
        }
        //for(int i:v) cout<<i<<" ";
        //    cout<<endl;
        int m=v.size();
        good[0]=true;
        for(int i=1;i<(1<<m);i++){
            int lg=log2(i);
            if(good[i-(1<<lg)]){
                bool b=true;
                for(int j=0;j<m;j++){
                    if((1<<j) & (i-(1<<lg)))
                        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++;
                }
                ans=max(ans, cnt+1);
            }
        }
        sz[idx]=INT_MAX;
        for(int i:adj[idx]) sz[i]--;
    }
    cout<<ans;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:58:16: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
         sz[idx]=INT_MAX;
                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 49 ms 3584 KB Output is correct
4 Correct 48 ms 3584 KB Output is correct
5 Correct 61 ms 3584 KB Output is correct
6 Correct 48 ms 3584 KB Output is correct
7 Correct 44 ms 3584 KB Output is correct
8 Incorrect 38 ms 2688 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 49 ms 3584 KB Output is correct
4 Correct 48 ms 3584 KB Output is correct
5 Correct 61 ms 3584 KB Output is correct
6 Correct 48 ms 3584 KB Output is correct
7 Correct 44 ms 3584 KB Output is correct
8 Incorrect 38 ms 2688 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 42 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 49 ms 3584 KB Output is correct
4 Correct 48 ms 3584 KB Output is correct
5 Correct 61 ms 3584 KB Output is correct
6 Correct 48 ms 3584 KB Output is correct
7 Correct 44 ms 3584 KB Output is correct
8 Incorrect 38 ms 2688 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 49 ms 3584 KB Output is correct
4 Correct 48 ms 3584 KB Output is correct
5 Correct 61 ms 3584 KB Output is correct
6 Correct 48 ms 3584 KB Output is correct
7 Correct 44 ms 3584 KB Output is correct
8 Incorrect 38 ms 2688 KB Output isn't correct
9 Halted 0 ms 0 KB -