Submission #1035669

# Submission time Handle Problem Language Result Execution time Memory
1035669 2024-07-26T13:15:05 Z vjudge1 Political Development (BOI17_politicaldevelopment) C++17
100 / 100
564 ms 335340 KB
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(), x.end()

const int N = 5e4;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, k, c, ans;
vector<int> vt, adj[N];
set<int> st[N];
bitset<N> bt[N], r, toTake;

void clean(int x) {
  for (int i = 0; i < n; i++) {
    if (adj[i].size()+1 < x) r[i] = 1;
  }
}

void dfs(int x) {
  c++;
  if (c > ans) {
    ans = c;
    clean(c+1);
  }

  vector<int> opt;
  for (int y = toTake._Find_first(); y < n; y = toTake._Find_next(y)) { 
    if (r[y]) continue;

    opt.push_back(y);
  }

  int sz = opt.size();
  if (!sz) return;

  int y = opt[rng() % sz];

  toTake &= bt[y];
  dfs(y);
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);

  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x; cin >> x;

    for (int j = 0; j < x; j++) {
      int y; cin >> y;
      st[i].insert(y);

      if (st[y].find(i) != st[y].end()) {
        bt[i][y] = 1;
        adj[i].push_back(y);

        bt[y][i] = 1;
        adj[y].push_back(i);
      }
    }
  }

  ans = 1;
  for (int i = 0; i < n*3; i++) {
    c = 0;
    toTake = bt[i%n];
    dfs(i%n);
  }

  cout << ans << "\n";
}

Compilation message

politicaldevelopment.cpp: In function 'void clean(int)':
politicaldevelopment.cpp:19:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     if (adj[i].size()+1 < x) r[i] = 1;
      |         ~~~~~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3932 KB Output is correct
2 Correct 2 ms 3804 KB Output is correct
3 Correct 26 ms 25180 KB Output is correct
4 Correct 26 ms 24668 KB Output is correct
5 Correct 25 ms 24668 KB Output is correct
6 Correct 23 ms 24552 KB Output is correct
7 Correct 24 ms 24668 KB Output is correct
8 Correct 7 ms 3932 KB Output is correct
9 Correct 2 ms 3932 KB Output is correct
10 Correct 7 ms 3932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3932 KB Output is correct
2 Correct 2 ms 3804 KB Output is correct
3 Correct 26 ms 25180 KB Output is correct
4 Correct 26 ms 24668 KB Output is correct
5 Correct 25 ms 24668 KB Output is correct
6 Correct 23 ms 24552 KB Output is correct
7 Correct 24 ms 24668 KB Output is correct
8 Correct 7 ms 3932 KB Output is correct
9 Correct 2 ms 3932 KB Output is correct
10 Correct 7 ms 3932 KB Output is correct
11 Correct 23 ms 24664 KB Output is correct
12 Correct 23 ms 24636 KB Output is correct
13 Correct 2 ms 3932 KB Output is correct
14 Correct 23 ms 24668 KB Output is correct
15 Correct 2 ms 3932 KB Output is correct
16 Correct 24 ms 24772 KB Output is correct
17 Correct 2 ms 3928 KB Output is correct
18 Correct 23 ms 24664 KB Output is correct
19 Correct 6 ms 3932 KB Output is correct
20 Correct 17 ms 24408 KB Output is correct
21 Correct 17 ms 24412 KB Output is correct
22 Correct 7 ms 3840 KB Output is correct
23 Correct 27 ms 25692 KB Output is correct
24 Correct 7 ms 3932 KB Output is correct
25 Correct 28 ms 25736 KB Output is correct
26 Correct 25 ms 24892 KB Output is correct
27 Correct 23 ms 25648 KB Output is correct
28 Correct 25 ms 24924 KB Output is correct
29 Correct 25 ms 25692 KB Output is correct
30 Correct 27 ms 25688 KB Output is correct
31 Correct 28 ms 26160 KB Output is correct
32 Correct 27 ms 25692 KB Output is correct
33 Correct 28 ms 25948 KB Output is correct
34 Correct 27 ms 25852 KB Output is correct
35 Correct 13 ms 14684 KB Output is correct
36 Correct 14 ms 14684 KB Output is correct
37 Correct 13 ms 14664 KB Output is correct
38 Correct 7 ms 9308 KB Output is correct
39 Correct 7 ms 9308 KB Output is correct
40 Correct 27 ms 26632 KB Output is correct
41 Correct 9 ms 9308 KB Output is correct
42 Correct 31 ms 26564 KB Output is correct
43 Correct 37 ms 26712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3928 KB Output is correct
2 Correct 2 ms 3932 KB Output is correct
3 Correct 2 ms 3932 KB Output is correct
4 Correct 2 ms 3932 KB Output is correct
5 Correct 2 ms 3932 KB Output is correct
6 Correct 2 ms 3932 KB Output is correct
7 Correct 2 ms 3932 KB Output is correct
8 Correct 2 ms 4044 KB Output is correct
9 Correct 2 ms 3932 KB Output is correct
10 Correct 2 ms 3932 KB Output is correct
11 Correct 505 ms 335252 KB Output is correct
12 Correct 2 ms 3928 KB Output is correct
13 Correct 506 ms 335164 KB Output is correct
14 Correct 2 ms 3928 KB Output is correct
15 Correct 520 ms 335312 KB Output is correct
16 Correct 533 ms 335340 KB Output is correct
17 Correct 503 ms 335240 KB Output is correct
18 Correct 564 ms 335164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3932 KB Output is correct
2 Correct 2 ms 3804 KB Output is correct
3 Correct 26 ms 25180 KB Output is correct
4 Correct 26 ms 24668 KB Output is correct
5 Correct 25 ms 24668 KB Output is correct
6 Correct 23 ms 24552 KB Output is correct
7 Correct 24 ms 24668 KB Output is correct
8 Correct 7 ms 3932 KB Output is correct
9 Correct 2 ms 3932 KB Output is correct
10 Correct 7 ms 3932 KB Output is correct
11 Correct 23 ms 24664 KB Output is correct
12 Correct 23 ms 24636 KB Output is correct
13 Correct 2 ms 3932 KB Output is correct
14 Correct 23 ms 24668 KB Output is correct
15 Correct 2 ms 3932 KB Output is correct
16 Correct 24 ms 24772 KB Output is correct
17 Correct 2 ms 3928 KB Output is correct
18 Correct 23 ms 24664 KB Output is correct
19 Correct 6 ms 3932 KB Output is correct
20 Correct 17 ms 24408 KB Output is correct
21 Correct 17 ms 24412 KB Output is correct
22 Correct 7 ms 3840 KB Output is correct
23 Correct 27 ms 25692 KB Output is correct
24 Correct 7 ms 3932 KB Output is correct
25 Correct 28 ms 25736 KB Output is correct
26 Correct 25 ms 24892 KB Output is correct
27 Correct 23 ms 25648 KB Output is correct
28 Correct 25 ms 24924 KB Output is correct
29 Correct 25 ms 25692 KB Output is correct
30 Correct 27 ms 25688 KB Output is correct
31 Correct 28 ms 26160 KB Output is correct
32 Correct 27 ms 25692 KB Output is correct
33 Correct 28 ms 25948 KB Output is correct
34 Correct 27 ms 25852 KB Output is correct
35 Correct 13 ms 14684 KB Output is correct
36 Correct 14 ms 14684 KB Output is correct
37 Correct 13 ms 14664 KB Output is correct
38 Correct 7 ms 9308 KB Output is correct
39 Correct 7 ms 9308 KB Output is correct
40 Correct 27 ms 26632 KB Output is correct
41 Correct 9 ms 9308 KB Output is correct
42 Correct 31 ms 26564 KB Output is correct
43 Correct 37 ms 26712 KB Output is correct
44 Correct 28 ms 28504 KB Output is correct
45 Correct 2 ms 3932 KB Output is correct
46 Correct 29 ms 26452 KB Output is correct
47 Correct 38 ms 28508 KB Output is correct
48 Correct 34 ms 26712 KB Output is correct
49 Correct 46 ms 28684 KB Output is correct
50 Correct 38 ms 28508 KB Output is correct
51 Correct 59 ms 31260 KB Output is correct
52 Correct 33 ms 24744 KB Output is correct
53 Correct 57 ms 32084 KB Output is correct
54 Correct 51 ms 31884 KB Output is correct
55 Correct 29 ms 24736 KB Output is correct
56 Correct 24 ms 24520 KB Output is correct
57 Correct 7 ms 3932 KB Output is correct
58 Correct 57 ms 31960 KB Output is correct
59 Correct 24 ms 26972 KB Output is correct
60 Correct 31 ms 24668 KB Output is correct
61 Correct 26 ms 26972 KB Output is correct
62 Correct 23 ms 26972 KB Output is correct
63 Correct 32 ms 28732 KB Output is correct
64 Correct 28 ms 28400 KB Output is correct
65 Correct 31 ms 26460 KB Output is correct
66 Correct 25 ms 27000 KB Output is correct
67 Correct 52 ms 29172 KB Output is correct
68 Correct 35 ms 28372 KB Output is correct
69 Correct 31 ms 26456 KB Output is correct
70 Correct 40 ms 28248 KB Output is correct
71 Correct 48 ms 29020 KB Output is correct
72 Correct 57 ms 29020 KB Output is correct
73 Correct 29 ms 25692 KB Output is correct
74 Correct 42 ms 28392 KB Output is correct
75 Correct 57 ms 29004 KB Output is correct
76 Correct 31 ms 27480 KB Output is correct
77 Correct 47 ms 30016 KB Output is correct
78 Correct 34 ms 25708 KB Output is correct
79 Correct 22 ms 16288 KB Output is correct
80 Correct 34 ms 27480 KB Output is correct
81 Correct 44 ms 29944 KB Output is correct
82 Correct 8 ms 9136 KB Output is correct
83 Correct 19 ms 16260 KB Output is correct
84 Correct 44 ms 29016 KB Output is correct
85 Correct 8 ms 9340 KB Output is correct
86 Correct 40 ms 29016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3932 KB Output is correct
2 Correct 2 ms 3804 KB Output is correct
3 Correct 26 ms 25180 KB Output is correct
4 Correct 26 ms 24668 KB Output is correct
5 Correct 25 ms 24668 KB Output is correct
6 Correct 23 ms 24552 KB Output is correct
7 Correct 24 ms 24668 KB Output is correct
8 Correct 7 ms 3932 KB Output is correct
9 Correct 2 ms 3932 KB Output is correct
10 Correct 7 ms 3932 KB Output is correct
11 Correct 23 ms 24664 KB Output is correct
12 Correct 23 ms 24636 KB Output is correct
13 Correct 2 ms 3932 KB Output is correct
14 Correct 23 ms 24668 KB Output is correct
15 Correct 2 ms 3932 KB Output is correct
16 Correct 24 ms 24772 KB Output is correct
17 Correct 2 ms 3928 KB Output is correct
18 Correct 23 ms 24664 KB Output is correct
19 Correct 6 ms 3932 KB Output is correct
20 Correct 17 ms 24408 KB Output is correct
21 Correct 17 ms 24412 KB Output is correct
22 Correct 7 ms 3840 KB Output is correct
23 Correct 27 ms 25692 KB Output is correct
24 Correct 7 ms 3932 KB Output is correct
25 Correct 28 ms 25736 KB Output is correct
26 Correct 25 ms 24892 KB Output is correct
27 Correct 23 ms 25648 KB Output is correct
28 Correct 25 ms 24924 KB Output is correct
29 Correct 25 ms 25692 KB Output is correct
30 Correct 27 ms 25688 KB Output is correct
31 Correct 28 ms 26160 KB Output is correct
32 Correct 27 ms 25692 KB Output is correct
33 Correct 28 ms 25948 KB Output is correct
34 Correct 27 ms 25852 KB Output is correct
35 Correct 13 ms 14684 KB Output is correct
36 Correct 14 ms 14684 KB Output is correct
37 Correct 13 ms 14664 KB Output is correct
38 Correct 7 ms 9308 KB Output is correct
39 Correct 7 ms 9308 KB Output is correct
40 Correct 27 ms 26632 KB Output is correct
41 Correct 9 ms 9308 KB Output is correct
42 Correct 31 ms 26564 KB Output is correct
43 Correct 37 ms 26712 KB Output is correct
44 Correct 2 ms 3932 KB Output is correct
45 Correct 458 ms 320852 KB Output is correct
46 Correct 439 ms 287132 KB Output is correct
47 Correct 485 ms 321564 KB Output is correct
48 Correct 482 ms 322812 KB Output is correct
49 Correct 288 ms 211784 KB Output is correct
50 Correct 396 ms 333984 KB Output is correct
51 Correct 469 ms 321504 KB Output is correct
52 Correct 259 ms 198232 KB Output is correct
53 Correct 262 ms 211568 KB Output is correct
54 Correct 64 ms 4664 KB Output is correct
55 Correct 397 ms 333996 KB Output is correct
56 Correct 184 ms 194676 KB Output is correct
57 Correct 266 ms 199252 KB Output is correct
58 Correct 259 ms 300624 KB Output is correct
59 Correct 200 ms 194932 KB Output is correct
60 Correct 194 ms 194896 KB Output is correct
61 Correct 259 ms 300460 KB Output is correct
62 Correct 241 ms 269288 KB Output is correct
63 Correct 411 ms 295888 KB Output is correct
64 Correct 183 ms 194732 KB Output is correct
65 Correct 460 ms 308964 KB Output is correct
66 Correct 232 ms 270072 KB Output is correct
67 Correct 403 ms 295660 KB Output is correct
68 Correct 457 ms 306236 KB Output is correct
69 Correct 483 ms 307988 KB Output is correct
70 Correct 338 ms 269408 KB Output is correct
71 Correct 411 ms 306516 KB Output is correct
72 Correct 395 ms 286276 KB Output is correct
73 Correct 432 ms 321744 KB Output is correct
74 Correct 340 ms 269652 KB Output is correct
75 Correct 190 ms 150356 KB Output is correct
76 Correct 349 ms 279252 KB Output is correct
77 Correct 403 ms 321872 KB Output is correct
78 Correct 188 ms 157524 KB Output is correct
79 Correct 188 ms 150608 KB Output is correct
80 Correct 73 ms 63312 KB Output is correct
81 Correct 185 ms 157268 KB Output is correct
82 Correct 377 ms 314448 KB Output is correct
83 Correct 74 ms 63712 KB Output is correct
84 Correct 378 ms 314304 KB Output is correct