답안 #1103338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103338 2024-10-20T17:02:11 Z alexdd Political Development (BOI17_politicaldevelopment) C++17
4 / 100
7 ms 3580 KB
#include <bits/stdc++.h>
using namespace std;
int n,k,mxm;
set<int> con[50005];
set<pair<int,int>> s;
int b[20];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>k;
    mxm=1;
    for(int i=1;i<=n;i++)
    {
        int nr,x;
        cin>>nr;
        for(int j=0;j<nr;j++)
        {
            cin>>x;
            x++;
            con[i].insert(x);
        }
        s.insert({nr,i});
    }
    for(int pas=1;pas<=n;pas++)
    {
        auto it = s.begin();
        int nod = (*it).second;
        s.erase(it);

        vector<int> v;
        for(auto j:con[nod])
            v.push_back(j);
        assert((int)v.size() < k);

        for(int config=1;config<(1<<((int)v.size()));config++)
        {
            int cnt=0;
            for(int j=0;j<v.size();j++)
            {
                if((1<<j)&config)
                {
                    b[cnt++]=j;
                }
            }
            if(cnt+1>mxm)
            {
                bool bun=1;
                for(int i=0;i<cnt;i++)
                {
                    for(int j=i+1;j<cnt;j++)
                    {
                        if(con[b[i]].find(b[j])==con[b[i]].end())
                        {
                            bun=0;
                            break;
                        }
                    }
                    if(!bun)
                        break;
                }
                if(bun)
                {
                    mxm = cnt+1;
                    if(mxm==k)
                    {
                        cout<<k;
                        return 0;
                    }
                }
            }
        }

        for(auto j:con[nod])
        {
            s.erase({con[j].size(),j});
            con[j].erase(nod);
            s.insert({con[j].size(),j});
        }
    }
    cout<<mxm;
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:38:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             for(int j=0;j<v.size();j++)
      |                         ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 3 ms 3408 KB Output is correct
4 Correct 4 ms 3316 KB Output is correct
5 Correct 3 ms 3408 KB Output is correct
6 Correct 4 ms 3408 KB Output is correct
7 Correct 5 ms 3408 KB Output is correct
8 Correct 2 ms 2896 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 2 ms 2896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 3 ms 3408 KB Output is correct
4 Correct 4 ms 3316 KB Output is correct
5 Correct 3 ms 3408 KB Output is correct
6 Correct 4 ms 3408 KB Output is correct
7 Correct 5 ms 3408 KB Output is correct
8 Correct 2 ms 2896 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 2 ms 2896 KB Output is correct
11 Correct 4 ms 3408 KB Output is correct
12 Correct 7 ms 3408 KB Output is correct
13 Correct 1 ms 2640 KB Output is correct
14 Correct 6 ms 3580 KB Output is correct
15 Incorrect 1 ms 2640 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2896 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 2 ms 2656 KB Output is correct
4 Incorrect 1 ms 2812 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 3 ms 3408 KB Output is correct
4 Correct 4 ms 3316 KB Output is correct
5 Correct 3 ms 3408 KB Output is correct
6 Correct 4 ms 3408 KB Output is correct
7 Correct 5 ms 3408 KB Output is correct
8 Correct 2 ms 2896 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 2 ms 2896 KB Output is correct
11 Correct 4 ms 3408 KB Output is correct
12 Correct 7 ms 3408 KB Output is correct
13 Correct 1 ms 2640 KB Output is correct
14 Correct 6 ms 3580 KB Output is correct
15 Incorrect 1 ms 2640 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 3 ms 3408 KB Output is correct
4 Correct 4 ms 3316 KB Output is correct
5 Correct 3 ms 3408 KB Output is correct
6 Correct 4 ms 3408 KB Output is correct
7 Correct 5 ms 3408 KB Output is correct
8 Correct 2 ms 2896 KB Output is correct
9 Correct 1 ms 2640 KB Output is correct
10 Correct 2 ms 2896 KB Output is correct
11 Correct 4 ms 3408 KB Output is correct
12 Correct 7 ms 3408 KB Output is correct
13 Correct 1 ms 2640 KB Output is correct
14 Correct 6 ms 3580 KB Output is correct
15 Incorrect 1 ms 2640 KB Output isn't correct
16 Halted 0 ms 0 KB -