답안 #135721

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
135721 2019-07-24T10:04:46 Z miguel Political Development (BOI17_politicaldevelopment) C++14
4 / 100
3000 ms 47480 KB
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
#define nmax 301
const ll mod = 998244353;
int n, m, k, viz[50001], deg[50001], ans;
set<int> g[50001];
set <pi> edg;
priority_queue<pi, vector<pi>, greater<pi>> pq;

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    //cin>>n;for(int i=1; i<=n; i++){int x; cin>>x; pq.push(x);};while(!pq.empty()){int x=pq.top(); pq.pop(); cout<<x<<" ";}
    cin>>n>>k;
    for(int i=0; i<n; i++){
        cin>>deg[i];
        pq.push({deg[i], i});
        for(int j=1; j<=deg[i]; j++){
            int x;
            cin>>x;
            g[i].insert(x);
            edg.insert({i, x});
        }
    }
    //for(pi i: edg){ cout<<i.x<<" "<<i.y<<"\n";}
    //cout<<"\n";
    while(true){
        //cout<<"xd"<<endl;
        while(!pq.empty() && viz[pq.top().x]) pq.pop();
        if(pq.empty()) break;
        int a=pq.top().y;
        pq.pop();
        deg[a]=0;
        viz[a]=1;
        vi v={a};
        for(int i : g[a]){
            if(!viz[i]){
                deg[i]--;
                pq.push({deg[i], i});
                v.pb(i);
            }
        }
        //assert(v.size()<=10);
        //for(int i : v) cout<<i<<" "; cout<<endl;
        bool adj[5000][5000];
        for(int i=0; i<v.size(); i++){
            //a[i][j]=0;
            for(int j=0; j<v.size(); j++){
                if(i!=j && edg.find({v[i], v[j]})!=edg.end()){
                    adj[i][j]=1;
                }
                else adj[i][j]=0;
            }
        }
        for(int mask=1; mask<(1<<v.size()); mask+=2){
            bool ctrl=1;
            int cnt=0;
            for(int i=0; i<v.size(); i++){
                if((mask>>i)%2==0) continue;
                cnt++;
                for(int j=0; j<v.size(); j++){
                    if((mask>>j)%2==0) continue;
                    if(i!=j && adj[i][j]==0) ctrl=0;
                }
            }
            if(ctrl) ans=max(ans, cnt);
        }
    }
    cout<<ans<<endl;
}

Compilation message

politicaldevelopment.cpp: In function 'int32_t main()':
politicaldevelopment.cpp:55:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0; i<v.size(); i++){
                      ~^~~~~~~~~
politicaldevelopment.cpp:57:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j=0; j<v.size(); j++){
                          ~^~~~~~~~~
politicaldevelopment.cpp:67:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i=0; i<v.size(); i++){
                          ~^~~~~~~~~
politicaldevelopment.cpp:70:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for(int j=0; j<v.size(); j++){
                              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 14 ms 3704 KB Output is correct
4 Correct 1392 ms 28268 KB Output is correct
5 Correct 1313 ms 28316 KB Output is correct
6 Correct 46 ms 3960 KB Output is correct
7 Correct 53 ms 3960 KB Output is correct
8 Correct 5 ms 2808 KB Output is correct
9 Correct 4 ms 2684 KB Output is correct
10 Correct 5 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 14 ms 3704 KB Output is correct
4 Correct 1392 ms 28268 KB Output is correct
5 Correct 1313 ms 28316 KB Output is correct
6 Correct 46 ms 3960 KB Output is correct
7 Correct 53 ms 3960 KB Output is correct
8 Correct 5 ms 2808 KB Output is correct
9 Correct 4 ms 2684 KB Output is correct
10 Correct 5 ms 2808 KB Output is correct
11 Correct 1362 ms 28252 KB Output is correct
12 Correct 1305 ms 28260 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 1270 ms 28248 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 51 ms 3960 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 46 ms 4056 KB Output is correct
19 Correct 5 ms 2808 KB Output is correct
20 Correct 7 ms 3192 KB Output is correct
21 Correct 7 ms 3192 KB Output is correct
22 Correct 5 ms 2856 KB Output is correct
23 Correct 13 ms 3932 KB Output is correct
24 Correct 5 ms 2808 KB Output is correct
25 Correct 14 ms 4036 KB Output is correct
26 Correct 14 ms 3832 KB Output is correct
27 Correct 12 ms 3776 KB Output is correct
28 Correct 13 ms 3892 KB Output is correct
29 Correct 11 ms 3704 KB Output is correct
30 Execution timed out 3082 ms 6928 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2808 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 4 ms 2728 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 5 ms 2728 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 4 ms 2764 KB Output is correct
11 Correct 1010 ms 47480 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Incorrect 949 ms 46472 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 14 ms 3704 KB Output is correct
4 Correct 1392 ms 28268 KB Output is correct
5 Correct 1313 ms 28316 KB Output is correct
6 Correct 46 ms 3960 KB Output is correct
7 Correct 53 ms 3960 KB Output is correct
8 Correct 5 ms 2808 KB Output is correct
9 Correct 4 ms 2684 KB Output is correct
10 Correct 5 ms 2808 KB Output is correct
11 Correct 1362 ms 28252 KB Output is correct
12 Correct 1305 ms 28260 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 1270 ms 28248 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 51 ms 3960 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 46 ms 4056 KB Output is correct
19 Correct 5 ms 2808 KB Output is correct
20 Correct 7 ms 3192 KB Output is correct
21 Correct 7 ms 3192 KB Output is correct
22 Correct 5 ms 2856 KB Output is correct
23 Correct 13 ms 3932 KB Output is correct
24 Correct 5 ms 2808 KB Output is correct
25 Correct 14 ms 4036 KB Output is correct
26 Correct 14 ms 3832 KB Output is correct
27 Correct 12 ms 3776 KB Output is correct
28 Correct 13 ms 3892 KB Output is correct
29 Correct 11 ms 3704 KB Output is correct
30 Execution timed out 3082 ms 6928 KB Time limit exceeded
31 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 14 ms 3704 KB Output is correct
4 Correct 1392 ms 28268 KB Output is correct
5 Correct 1313 ms 28316 KB Output is correct
6 Correct 46 ms 3960 KB Output is correct
7 Correct 53 ms 3960 KB Output is correct
8 Correct 5 ms 2808 KB Output is correct
9 Correct 4 ms 2684 KB Output is correct
10 Correct 5 ms 2808 KB Output is correct
11 Correct 1362 ms 28252 KB Output is correct
12 Correct 1305 ms 28260 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 1270 ms 28248 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 51 ms 3960 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 46 ms 4056 KB Output is correct
19 Correct 5 ms 2808 KB Output is correct
20 Correct 7 ms 3192 KB Output is correct
21 Correct 7 ms 3192 KB Output is correct
22 Correct 5 ms 2856 KB Output is correct
23 Correct 13 ms 3932 KB Output is correct
24 Correct 5 ms 2808 KB Output is correct
25 Correct 14 ms 4036 KB Output is correct
26 Correct 14 ms 3832 KB Output is correct
27 Correct 12 ms 3776 KB Output is correct
28 Correct 13 ms 3892 KB Output is correct
29 Correct 11 ms 3704 KB Output is correct
30 Execution timed out 3082 ms 6928 KB Time limit exceeded
31 Halted 0 ms 0 KB -