Submission #1115870

# Submission time Handle Problem Language Result Execution time Memory
1115870 2024-11-21T02:59:43 Z vjudge1 Political Development (BOI17_politicaldevelopment) C++17
100 / 100
1607 ms 306568 KB
#include <bits/stdc++.h>
using namespace std;

#define name "TENBAI"
#define fi first
#define se second
#define int long long
#define endl '\n'
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))

mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}

const int NM = 5e4 + 5;

int ans = 1, n, k;
bitset<NM> g[NM];

void dfs(int sz, const bitset<NM>& bs)
{
    setmax(ans, sz);
    for (int i = bs._Find_first(); i < n; i = bs._Find_next(i))
        dfs(sz + 1, bs & g[i]);
}

void sub1()
{
    vector<vector<int>> v;
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        while (t--)
        {
            int x;
            cin >> x;
            g[i][x] = 1;
        }
        for (int k = v.size(), j = 0; j < k; j++)
        {
            bool sus = 0;
            for (int x : v[j])
                if (!g[i][x])
                {
                    sus = 1;
                    break;
                }
            if (!sus)
            {
                v.push_back(v[j]);
                v.back().push_back(i);
                setmax(ans, (int)v.back().size());
            }
        }
        v.push_back(vector<int>(1, i));
    }
    cout << ans;
}

void sub2()
{
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        while (t--)
        {
            int x;
            cin >> x;
            g[i][x] = 1;
        }
    }
    for (int i = 0; i < n; i++)
        dfs(1, g[i]);
    cout << ans;
}

void solve()
{
    cin >> n >> k;
    if (n <= 5000)
        sub1();
    else
        sub2();
}

signed main()
{
    if (fopen("in.txt", "r")) 
    {
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
    else if (fopen(name".inp", "r"))
    {
        freopen(name".inp", "r", stdin);
        freopen(name".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int tc = 1; 
    // cin >> tc;
    while (tc--)
        solve();
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:93:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |         freopen("in.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:94:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |         freopen("out.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:98:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   98 |         freopen(name".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:99:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   99 |         freopen(name".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 54 ms 32132 KB Output is correct
4 Correct 44 ms 31720 KB Output is correct
5 Correct 45 ms 31876 KB Output is correct
6 Correct 38 ms 31840 KB Output is correct
7 Correct 36 ms 31876 KB Output is correct
8 Correct 21 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 21 ms 712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 54 ms 32132 KB Output is correct
4 Correct 44 ms 31720 KB Output is correct
5 Correct 45 ms 31876 KB Output is correct
6 Correct 38 ms 31840 KB Output is correct
7 Correct 36 ms 31876 KB Output is correct
8 Correct 21 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 21 ms 712 KB Output is correct
11 Correct 46 ms 31876 KB Output is correct
12 Correct 56 ms 31876 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 37 ms 31804 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 37 ms 31728 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 39 ms 31884 KB Output is correct
19 Correct 20 ms 1016 KB Output is correct
20 Correct 32 ms 31572 KB Output is correct
21 Correct 28 ms 31560 KB Output is correct
22 Correct 28 ms 848 KB Output is correct
23 Correct 37 ms 31884 KB Output is correct
24 Correct 19 ms 848 KB Output is correct
25 Correct 38 ms 31968 KB Output is correct
26 Correct 36 ms 31772 KB Output is correct
27 Correct 35 ms 31884 KB Output is correct
28 Correct 36 ms 31872 KB Output is correct
29 Correct 35 ms 31884 KB Output is correct
30 Correct 42 ms 31844 KB Output is correct
31 Correct 39 ms 31876 KB Output is correct
32 Correct 50 ms 31992 KB Output is correct
33 Correct 72 ms 31876 KB Output is correct
34 Correct 40 ms 31876 KB Output is correct
35 Correct 12 ms 17232 KB Output is correct
36 Correct 12 ms 17244 KB Output is correct
37 Correct 12 ms 17244 KB Output is correct
38 Correct 5 ms 8784 KB Output is correct
39 Correct 5 ms 8784 KB Output is correct
40 Correct 48 ms 32132 KB Output is correct
41 Correct 9 ms 8784 KB Output is correct
42 Correct 48 ms 32140 KB Output is correct
43 Correct 49 ms 32096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 848 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 556 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 884 ms 306456 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1579 ms 306512 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 698 ms 306416 KB Output is correct
16 Correct 783 ms 306564 KB Output is correct
17 Correct 1607 ms 306568 KB Output is correct
18 Correct 805 ms 306512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 54 ms 32132 KB Output is correct
4 Correct 44 ms 31720 KB Output is correct
5 Correct 45 ms 31876 KB Output is correct
6 Correct 38 ms 31840 KB Output is correct
7 Correct 36 ms 31876 KB Output is correct
8 Correct 21 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 21 ms 712 KB Output is correct
11 Correct 46 ms 31876 KB Output is correct
12 Correct 56 ms 31876 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 37 ms 31804 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 37 ms 31728 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 39 ms 31884 KB Output is correct
19 Correct 20 ms 1016 KB Output is correct
20 Correct 32 ms 31572 KB Output is correct
21 Correct 28 ms 31560 KB Output is correct
22 Correct 28 ms 848 KB Output is correct
23 Correct 37 ms 31884 KB Output is correct
24 Correct 19 ms 848 KB Output is correct
25 Correct 38 ms 31968 KB Output is correct
26 Correct 36 ms 31772 KB Output is correct
27 Correct 35 ms 31884 KB Output is correct
28 Correct 36 ms 31872 KB Output is correct
29 Correct 35 ms 31884 KB Output is correct
30 Correct 42 ms 31844 KB Output is correct
31 Correct 39 ms 31876 KB Output is correct
32 Correct 50 ms 31992 KB Output is correct
33 Correct 72 ms 31876 KB Output is correct
34 Correct 40 ms 31876 KB Output is correct
35 Correct 12 ms 17232 KB Output is correct
36 Correct 12 ms 17244 KB Output is correct
37 Correct 12 ms 17244 KB Output is correct
38 Correct 5 ms 8784 KB Output is correct
39 Correct 5 ms 8784 KB Output is correct
40 Correct 48 ms 32132 KB Output is correct
41 Correct 9 ms 8784 KB Output is correct
42 Correct 48 ms 32140 KB Output is correct
43 Correct 49 ms 32096 KB Output is correct
44 Correct 510 ms 60956 KB Output is correct
45 Correct 1 ms 336 KB Output is correct
46 Correct 47 ms 32140 KB Output is correct
47 Correct 81 ms 30156 KB Output is correct
48 Correct 53 ms 27524 KB Output is correct
49 Correct 114 ms 26368 KB Output is correct
50 Correct 84 ms 26256 KB Output is correct
51 Correct 145 ms 29188 KB Output is correct
52 Correct 58 ms 25292 KB Output is correct
53 Correct 177 ms 27900 KB Output is correct
54 Correct 160 ms 30108 KB Output is correct
55 Correct 42 ms 28804 KB Output is correct
56 Correct 58 ms 27268 KB Output is correct
57 Correct 22 ms 1016 KB Output is correct
58 Correct 175 ms 34044 KB Output is correct
59 Correct 89 ms 33280 KB Output is correct
60 Correct 37 ms 31724 KB Output is correct
61 Correct 79 ms 33284 KB Output is correct
62 Correct 76 ms 33240 KB Output is correct
63 Correct 554 ms 63980 KB Output is correct
64 Correct 310 ms 46580 KB Output is correct
65 Correct 45 ms 32132 KB Output is correct
66 Correct 133 ms 33220 KB Output is correct
67 Correct 209 ms 39160 KB Output is correct
68 Correct 320 ms 46628 KB Output is correct
69 Correct 52 ms 32132 KB Output is correct
70 Correct 108 ms 33280 KB Output is correct
71 Correct 216 ms 39340 KB Output is correct
72 Correct 161 ms 35976 KB Output is correct
73 Correct 38 ms 31876 KB Output is correct
74 Correct 104 ms 33196 KB Output is correct
75 Correct 161 ms 36092 KB Output is correct
76 Correct 78 ms 32224 KB Output is correct
77 Correct 109 ms 33788 KB Output is correct
78 Correct 37 ms 31884 KB Output is correct
79 Correct 29 ms 18060 KB Output is correct
80 Correct 89 ms 32172 KB Output is correct
81 Correct 100 ms 33792 KB Output is correct
82 Correct 9 ms 8796 KB Output is correct
83 Correct 30 ms 18052 KB Output is correct
84 Correct 95 ms 32804 KB Output is correct
85 Correct 9 ms 8784 KB Output is correct
86 Correct 85 ms 32768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 54 ms 32132 KB Output is correct
4 Correct 44 ms 31720 KB Output is correct
5 Correct 45 ms 31876 KB Output is correct
6 Correct 38 ms 31840 KB Output is correct
7 Correct 36 ms 31876 KB Output is correct
8 Correct 21 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 21 ms 712 KB Output is correct
11 Correct 46 ms 31876 KB Output is correct
12 Correct 56 ms 31876 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 37 ms 31804 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 37 ms 31728 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 39 ms 31884 KB Output is correct
19 Correct 20 ms 1016 KB Output is correct
20 Correct 32 ms 31572 KB Output is correct
21 Correct 28 ms 31560 KB Output is correct
22 Correct 28 ms 848 KB Output is correct
23 Correct 37 ms 31884 KB Output is correct
24 Correct 19 ms 848 KB Output is correct
25 Correct 38 ms 31968 KB Output is correct
26 Correct 36 ms 31772 KB Output is correct
27 Correct 35 ms 31884 KB Output is correct
28 Correct 36 ms 31872 KB Output is correct
29 Correct 35 ms 31884 KB Output is correct
30 Correct 42 ms 31844 KB Output is correct
31 Correct 39 ms 31876 KB Output is correct
32 Correct 50 ms 31992 KB Output is correct
33 Correct 72 ms 31876 KB Output is correct
34 Correct 40 ms 31876 KB Output is correct
35 Correct 12 ms 17232 KB Output is correct
36 Correct 12 ms 17244 KB Output is correct
37 Correct 12 ms 17244 KB Output is correct
38 Correct 5 ms 8784 KB Output is correct
39 Correct 5 ms 8784 KB Output is correct
40 Correct 48 ms 32132 KB Output is correct
41 Correct 9 ms 8784 KB Output is correct
42 Correct 48 ms 32140 KB Output is correct
43 Correct 49 ms 32096 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 527 ms 305380 KB Output is correct
46 Correct 380 ms 296524 KB Output is correct
47 Correct 573 ms 303660 KB Output is correct
48 Correct 581 ms 305280 KB Output is correct
49 Correct 199 ms 284496 KB Output is correct
50 Correct 508 ms 306536 KB Output is correct
51 Correct 492 ms 305104 KB Output is correct
52 Correct 183 ms 292060 KB Output is correct
53 Correct 172 ms 295000 KB Output is correct
54 Correct 29 ms 872 KB Output is correct
55 Correct 476 ms 306528 KB Output is correct
56 Correct 130 ms 297544 KB Output is correct
57 Correct 185 ms 298312 KB Output is correct
58 Correct 825 ms 304184 KB Output is correct
59 Correct 135 ms 299848 KB Output is correct
60 Correct 146 ms 296008 KB Output is correct
61 Correct 798 ms 304840 KB Output is correct
62 Correct 293 ms 297756 KB Output is correct
63 Correct 335 ms 301896 KB Output is correct
64 Correct 139 ms 282956 KB Output is correct
65 Correct 543 ms 304204 KB Output is correct
66 Correct 306 ms 296776 KB Output is correct
67 Correct 330 ms 301836 KB Output is correct
68 Correct 393 ms 303176 KB Output is correct
69 Correct 529 ms 303920 KB Output is correct
70 Correct 225 ms 297288 KB Output is correct
71 Correct 402 ms 304712 KB Output is correct
72 Correct 325 ms 296524 KB Output is correct
73 Correct 459 ms 305644 KB Output is correct
74 Correct 235 ms 298568 KB Output is correct
75 Correct 160 ms 154312 KB Output is correct
76 Correct 315 ms 297288 KB Output is correct
77 Correct 413 ms 306044 KB Output is correct
78 Correct 204 ms 154696 KB Output is correct
79 Correct 147 ms 154448 KB Output is correct
80 Correct 69 ms 78416 KB Output is correct
81 Correct 179 ms 154444 KB Output is correct
82 Correct 334 ms 305224 KB Output is correct
83 Correct 65 ms 78416 KB Output is correct
84 Correct 345 ms 304968 KB Output is correct