답안 #310660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
310660 2020-10-07T14:41:36 Z MrDomino Political Development (BOI17_politicaldevelopment) C++14
77 / 100
3000 ms 8184 KB
#include <bits/stdc++.h>

using namespace std;

const int N=50000+7;
int n;
int k;
int sol;
vector<int> g[N];
set<pair<int,int>> s;

void del(int x)
{
        for (auto &i : g[x])
        {
                vector<int> gnew_i;
                for (auto &y : g[i])
                {
                        if (y!=x)
                                gnew_i.push_back(y);
                }
                s.erase({(int) g[i].size(),i});
                s.insert({(int) g[i].size()-1,i});
                g[i]=gnew_i;
        }
        g[x].clear();
}

bool on[N];
int sum[N];
int cur;

void bkt(int node)
{
        cur++;
        for (auto &it : g[node])
                sum[it]++;
        on[node]=1;
        if (cur>sol)
                sol=cur;
        int possible=0;
        vector<int>lol;
        for (auto &x : g[node])
        {
                if ((cur==1||(int)g[node].size()>=(int)g[x].size())&&on[x]==0&&sum[x]==cur)
                {
                        possible++;
                }
        }
        if (cur+possible<=sol)
        {
                on[node]=0;
                cur--;
                for (auto &it : g[node])
                        sum[it]--;
                return;
        }
        for (auto &x : g[node])
        {
                if ((cur==1||(int)g[node].size()>=(int)g[x].size())&&on[x]==0&&sum[x]==cur)
                {
                        bkt(x);
                }
        }
        on[node]=0;
        cur--;
        for (auto &it : g[node])
                sum[it]--;
}

int main()
{
        ios::sync_with_stdio(0);
        cin.tie(0);

        cin>>n>>k;
        for (int i=0;i<n;i++)
        {
                int l;
                cin>>l;
                for (int j=1;j<=l;j++)
                {
                        int x;
                        cin>>x;
                        g[i].push_back(x);
                }
                sort(g[i].begin(),g[i].end());
                s.insert({(int)g[i].size(),i});
        }
        while (!s.empty())
        {
                auto it=*s.begin();
                s.erase(it);
                int node=it.second;
                bkt(node);
                del(node);
        }
        cout<<sol<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 7 ms 1920 KB Output is correct
4 Correct 58 ms 2048 KB Output is correct
5 Correct 57 ms 2048 KB Output is correct
6 Correct 9 ms 1920 KB Output is correct
7 Correct 9 ms 1920 KB Output is correct
8 Correct 3 ms 1792 KB Output is correct
9 Correct 1 ms 1536 KB Output is correct
10 Correct 3 ms 1792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 7 ms 1920 KB Output is correct
4 Correct 58 ms 2048 KB Output is correct
5 Correct 57 ms 2048 KB Output is correct
6 Correct 9 ms 1920 KB Output is correct
7 Correct 9 ms 1920 KB Output is correct
8 Correct 3 ms 1792 KB Output is correct
9 Correct 1 ms 1536 KB Output is correct
10 Correct 3 ms 1792 KB Output is correct
11 Correct 57 ms 2060 KB Output is correct
12 Correct 58 ms 2048 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
14 Correct 58 ms 2168 KB Output is correct
15 Correct 1 ms 1536 KB Output is correct
16 Correct 9 ms 1920 KB Output is correct
17 Correct 1 ms 1536 KB Output is correct
18 Correct 9 ms 1920 KB Output is correct
19 Correct 3 ms 1792 KB Output is correct
20 Correct 4 ms 1920 KB Output is correct
21 Correct 4 ms 1920 KB Output is correct
22 Correct 3 ms 1792 KB Output is correct
23 Correct 8 ms 1920 KB Output is correct
24 Correct 3 ms 1792 KB Output is correct
25 Correct 8 ms 1920 KB Output is correct
26 Correct 7 ms 1920 KB Output is correct
27 Correct 6 ms 1920 KB Output is correct
28 Correct 9 ms 1920 KB Output is correct
29 Correct 7 ms 1920 KB Output is correct
30 Correct 25 ms 1920 KB Output is correct
31 Correct 8 ms 1920 KB Output is correct
32 Correct 25 ms 1920 KB Output is correct
33 Correct 8 ms 1920 KB Output is correct
34 Correct 8 ms 1920 KB Output is correct
35 Correct 4 ms 1664 KB Output is correct
36 Correct 4 ms 1664 KB Output is correct
37 Correct 5 ms 1664 KB Output is correct
38 Correct 4 ms 1664 KB Output is correct
39 Correct 4 ms 1664 KB Output is correct
40 Correct 12 ms 1920 KB Output is correct
41 Correct 5 ms 1664 KB Output is correct
42 Correct 14 ms 1920 KB Output is correct
43 Correct 12 ms 1920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1792 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 1 ms 1536 KB Output is correct
4 Correct 1 ms 1536 KB Output is correct
5 Correct 1 ms 1536 KB Output is correct
6 Correct 1 ms 1536 KB Output is correct
7 Correct 1 ms 1536 KB Output is correct
8 Correct 1 ms 1536 KB Output is correct
9 Correct 1 ms 1536 KB Output is correct
10 Correct 1 ms 1536 KB Output is correct
11 Correct 369 ms 8184 KB Output is correct
12 Correct 1 ms 1536 KB Output is correct
13 Correct 366 ms 8056 KB Output is correct
14 Correct 1 ms 1536 KB Output is correct
15 Correct 383 ms 8112 KB Output is correct
16 Correct 378 ms 8184 KB Output is correct
17 Correct 377 ms 8184 KB Output is correct
18 Correct 375 ms 8184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 7 ms 1920 KB Output is correct
4 Correct 58 ms 2048 KB Output is correct
5 Correct 57 ms 2048 KB Output is correct
6 Correct 9 ms 1920 KB Output is correct
7 Correct 9 ms 1920 KB Output is correct
8 Correct 3 ms 1792 KB Output is correct
9 Correct 1 ms 1536 KB Output is correct
10 Correct 3 ms 1792 KB Output is correct
11 Correct 57 ms 2060 KB Output is correct
12 Correct 58 ms 2048 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
14 Correct 58 ms 2168 KB Output is correct
15 Correct 1 ms 1536 KB Output is correct
16 Correct 9 ms 1920 KB Output is correct
17 Correct 1 ms 1536 KB Output is correct
18 Correct 9 ms 1920 KB Output is correct
19 Correct 3 ms 1792 KB Output is correct
20 Correct 4 ms 1920 KB Output is correct
21 Correct 4 ms 1920 KB Output is correct
22 Correct 3 ms 1792 KB Output is correct
23 Correct 8 ms 1920 KB Output is correct
24 Correct 3 ms 1792 KB Output is correct
25 Correct 8 ms 1920 KB Output is correct
26 Correct 7 ms 1920 KB Output is correct
27 Correct 6 ms 1920 KB Output is correct
28 Correct 9 ms 1920 KB Output is correct
29 Correct 7 ms 1920 KB Output is correct
30 Correct 25 ms 1920 KB Output is correct
31 Correct 8 ms 1920 KB Output is correct
32 Correct 25 ms 1920 KB Output is correct
33 Correct 8 ms 1920 KB Output is correct
34 Correct 8 ms 1920 KB Output is correct
35 Correct 4 ms 1664 KB Output is correct
36 Correct 4 ms 1664 KB Output is correct
37 Correct 5 ms 1664 KB Output is correct
38 Correct 4 ms 1664 KB Output is correct
39 Correct 4 ms 1664 KB Output is correct
40 Correct 12 ms 1920 KB Output is correct
41 Correct 5 ms 1664 KB Output is correct
42 Correct 14 ms 1920 KB Output is correct
43 Correct 12 ms 1920 KB Output is correct
44 Correct 16 ms 2048 KB Output is correct
45 Correct 1 ms 1536 KB Output is correct
46 Correct 13 ms 1920 KB Output is correct
47 Correct 25 ms 2048 KB Output is correct
48 Correct 12 ms 2028 KB Output is correct
49 Correct 26 ms 2048 KB Output is correct
50 Correct 26 ms 2048 KB Output is correct
51 Correct 54 ms 2304 KB Output is correct
52 Correct 56 ms 2048 KB Output is correct
53 Correct 1359 ms 2500 KB Output is correct
54 Correct 73 ms 2304 KB Output is correct
55 Correct 9 ms 2048 KB Output is correct
56 Correct 57 ms 2048 KB Output is correct
57 Correct 3 ms 1792 KB Output is correct
58 Correct 1358 ms 2552 KB Output is correct
59 Correct 9 ms 1920 KB Output is correct
60 Correct 9 ms 1920 KB Output is correct
61 Correct 9 ms 1920 KB Output is correct
62 Correct 9 ms 1920 KB Output is correct
63 Correct 16 ms 2048 KB Output is correct
64 Correct 15 ms 2048 KB Output is correct
65 Correct 11 ms 1920 KB Output is correct
66 Correct 11 ms 1920 KB Output is correct
67 Correct 28 ms 2168 KB Output is correct
68 Correct 14 ms 2048 KB Output is correct
69 Correct 10 ms 1920 KB Output is correct
70 Correct 20 ms 2048 KB Output is correct
71 Correct 28 ms 2168 KB Output is correct
72 Correct 27 ms 2176 KB Output is correct
73 Correct 6 ms 1920 KB Output is correct
74 Correct 21 ms 2048 KB Output is correct
75 Correct 29 ms 2048 KB Output is correct
76 Correct 49 ms 2048 KB Output is correct
77 Correct 35 ms 2176 KB Output is correct
78 Correct 6 ms 2048 KB Output is correct
79 Correct 17 ms 1792 KB Output is correct
80 Correct 46 ms 2168 KB Output is correct
81 Correct 35 ms 2176 KB Output is correct
82 Correct 5 ms 1664 KB Output is correct
83 Correct 22 ms 1792 KB Output is correct
84 Correct 26 ms 2176 KB Output is correct
85 Correct 4 ms 1664 KB Output is correct
86 Correct 26 ms 2176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1536 KB Output is correct
2 Correct 1 ms 1536 KB Output is correct
3 Correct 7 ms 1920 KB Output is correct
4 Correct 58 ms 2048 KB Output is correct
5 Correct 57 ms 2048 KB Output is correct
6 Correct 9 ms 1920 KB Output is correct
7 Correct 9 ms 1920 KB Output is correct
8 Correct 3 ms 1792 KB Output is correct
9 Correct 1 ms 1536 KB Output is correct
10 Correct 3 ms 1792 KB Output is correct
11 Correct 57 ms 2060 KB Output is correct
12 Correct 58 ms 2048 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
14 Correct 58 ms 2168 KB Output is correct
15 Correct 1 ms 1536 KB Output is correct
16 Correct 9 ms 1920 KB Output is correct
17 Correct 1 ms 1536 KB Output is correct
18 Correct 9 ms 1920 KB Output is correct
19 Correct 3 ms 1792 KB Output is correct
20 Correct 4 ms 1920 KB Output is correct
21 Correct 4 ms 1920 KB Output is correct
22 Correct 3 ms 1792 KB Output is correct
23 Correct 8 ms 1920 KB Output is correct
24 Correct 3 ms 1792 KB Output is correct
25 Correct 8 ms 1920 KB Output is correct
26 Correct 7 ms 1920 KB Output is correct
27 Correct 6 ms 1920 KB Output is correct
28 Correct 9 ms 1920 KB Output is correct
29 Correct 7 ms 1920 KB Output is correct
30 Correct 25 ms 1920 KB Output is correct
31 Correct 8 ms 1920 KB Output is correct
32 Correct 25 ms 1920 KB Output is correct
33 Correct 8 ms 1920 KB Output is correct
34 Correct 8 ms 1920 KB Output is correct
35 Correct 4 ms 1664 KB Output is correct
36 Correct 4 ms 1664 KB Output is correct
37 Correct 5 ms 1664 KB Output is correct
38 Correct 4 ms 1664 KB Output is correct
39 Correct 4 ms 1664 KB Output is correct
40 Correct 12 ms 1920 KB Output is correct
41 Correct 5 ms 1664 KB Output is correct
42 Correct 14 ms 1920 KB Output is correct
43 Correct 12 ms 1920 KB Output is correct
44 Correct 1 ms 1536 KB Output is correct
45 Correct 249 ms 6444 KB Output is correct
46 Correct 1633 ms 6192 KB Output is correct
47 Correct 253 ms 6520 KB Output is correct
48 Correct 248 ms 6520 KB Output is correct
49 Execution timed out 3060 ms 6968 KB Time limit exceeded
50 Halted 0 ms 0 KB -