Submission #1035434

# Submission time Handle Problem Language Result Execution time Memory
1035434 2024-07-26T11:02:39 Z vjudge1 Political Development (BOI17_politicaldevelopment) C++17
16 / 100
1637 ms 524288 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, /*X = 5e5, */X2 = 5e2;

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

int n, k, c, ans;
vector<int> vt, adj[N];
bitset<N> bt[N], bt2[N], taken, toTake;

void dfs2(int x) {
  if (c++ > X2) return;

  int sz = taken.count();
  ans = max(ans, sz);
  
  shuffle(all(adj[x]), rng);
  for (int& y : adj[x]) { 
    if (c++ > X2) return;
    if (!taken[y] && (taken & bt2[y]).count() < sz) continue;

    taken[y] = 1;
    bitset<N> toTakePrev = toTake;
    toTake &= bt2[y];

    dfs2(y);
    if (c++ > X2) return;

    toTake = toTakePrev;
    taken[y] = 0;
  }
}

/*
void dfs(int x) {
  if (c++ > X) return;

  int sz = taken.count();
  ans = max(ans, sz);

  shuffle(all(adj[x]), rng);
  for (int& y : adj[x]) {
    if (c++ > X) return;
    if (!taken[y] && (taken & bt2[y]).count() < sz) continue;

    taken[y] = 1;
    bitset<N> toTakePrev = toTake;
    toTake &= bt2[y];

    dfs(y);
    if (c++ > X) return;

    toTake = toTakePrev;
    taken[y] = 0;
  }
}
*/

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

  cin >> n >> k;
  //c = 0;
  ans = 1;
  vt.resize(n);
  for (int i = 0; i < n; i++) {
    vt[i] = i;
    bt2[i][i] = toTake[i] = 1;

    int x; cin >> x;
    for (int j = 0; j < x; j++) {
      int y; cin >> y;
      bt[i][y] = 1;

      if (bt[y][i]) {
        bt2[i][y] = 1;
        adj[i].push_back(y);

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

/*
  shuffle(all(vt), rng);
  for (int i = 0; i < n && c < X; i++) {
    dfs(vt[i]);
  }
  */

  shuffle(all(vt), rng);
  for (int i = 0; i < n; i++) {
    c = 0;

    taken.reset();
    taken[vt[i]] = 1;
    toTake = bt2[vt[i]];

    dfs2(vt[i]);
  }

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

Compilation message

politicaldevelopment.cpp: In function 'void dfs2(int)':
politicaldevelopment.cpp:25:47: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   25 |     if (!taken[y] && (taken & bt2[y]).count() < sz) continue;
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3164 KB Output is correct
2 Correct 3 ms 2908 KB Output is correct
3 Correct 833 ms 45420 KB Output is correct
4 Correct 1632 ms 43088 KB Output is correct
5 Correct 1637 ms 42584 KB Output is correct
6 Correct 1165 ms 43352 KB Output is correct
7 Correct 1178 ms 43600 KB Output is correct
8 Correct 14 ms 21596 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 15 ms 23312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3164 KB Output is correct
2 Correct 3 ms 2908 KB Output is correct
3 Correct 833 ms 45420 KB Output is correct
4 Correct 1632 ms 43088 KB Output is correct
5 Correct 1637 ms 42584 KB Output is correct
6 Correct 1165 ms 43352 KB Output is correct
7 Correct 1178 ms 43600 KB Output is correct
8 Correct 14 ms 21596 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 15 ms 23312 KB Output is correct
11 Correct 1633 ms 42892 KB Output is correct
12 Correct 1627 ms 42864 KB Output is correct
13 Correct 2 ms 2908 KB Output is correct
14 Correct 1575 ms 42764 KB Output is correct
15 Correct 2 ms 3160 KB Output is correct
16 Correct 1136 ms 43100 KB Output is correct
17 Correct 2 ms 3160 KB Output is correct
18 Correct 1199 ms 43600 KB Output is correct
19 Correct 14 ms 21592 KB Output is correct
20 Correct 668 ms 44552 KB Output is correct
21 Correct 635 ms 44632 KB Output is correct
22 Correct 15 ms 23128 KB Output is correct
23 Correct 807 ms 46052 KB Output is correct
24 Correct 16 ms 23132 KB Output is correct
25 Correct 821 ms 46328 KB Output is correct
26 Correct 780 ms 45380 KB Output is correct
27 Correct 781 ms 45656 KB Output is correct
28 Correct 767 ms 45196 KB Output is correct
29 Correct 769 ms 45916 KB Output is correct
30 Correct 1086 ms 45652 KB Output is correct
31 Correct 859 ms 46368 KB Output is correct
32 Correct 1061 ms 45648 KB Output is correct
33 Correct 773 ms 46240 KB Output is correct
34 Correct 797 ms 46160 KB Output is correct
35 Correct 408 ms 23640 KB Output is correct
36 Correct 408 ms 23644 KB Output is correct
37 Correct 407 ms 23644 KB Output is correct
38 Correct 272 ms 12288 KB Output is correct
39 Correct 278 ms 12120 KB Output is correct
40 Correct 905 ms 46576 KB Output is correct
41 Correct 279 ms 12124 KB Output is correct
42 Correct 914 ms 46928 KB Output is correct
43 Correct 907 ms 47060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 21596 KB Output is correct
2 Correct 5 ms 2908 KB Output is correct
3 Correct 6 ms 2712 KB Output is correct
4 Correct 3 ms 2908 KB Output is correct
5 Correct 5 ms 3260 KB Output is correct
6 Correct 5 ms 3164 KB Output is correct
7 Correct 5 ms 3164 KB Output is correct
8 Correct 5 ms 2908 KB Output is correct
9 Correct 5 ms 3164 KB Output is correct
10 Correct 5 ms 2908 KB Output is correct
11 Runtime error 261 ms 524288 KB Execution killed with signal 9
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3164 KB Output is correct
2 Correct 3 ms 2908 KB Output is correct
3 Correct 833 ms 45420 KB Output is correct
4 Correct 1632 ms 43088 KB Output is correct
5 Correct 1637 ms 42584 KB Output is correct
6 Correct 1165 ms 43352 KB Output is correct
7 Correct 1178 ms 43600 KB Output is correct
8 Correct 14 ms 21596 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 15 ms 23312 KB Output is correct
11 Correct 1633 ms 42892 KB Output is correct
12 Correct 1627 ms 42864 KB Output is correct
13 Correct 2 ms 2908 KB Output is correct
14 Correct 1575 ms 42764 KB Output is correct
15 Correct 2 ms 3160 KB Output is correct
16 Correct 1136 ms 43100 KB Output is correct
17 Correct 2 ms 3160 KB Output is correct
18 Correct 1199 ms 43600 KB Output is correct
19 Correct 14 ms 21592 KB Output is correct
20 Correct 668 ms 44552 KB Output is correct
21 Correct 635 ms 44632 KB Output is correct
22 Correct 15 ms 23128 KB Output is correct
23 Correct 807 ms 46052 KB Output is correct
24 Correct 16 ms 23132 KB Output is correct
25 Correct 821 ms 46328 KB Output is correct
26 Correct 780 ms 45380 KB Output is correct
27 Correct 781 ms 45656 KB Output is correct
28 Correct 767 ms 45196 KB Output is correct
29 Correct 769 ms 45916 KB Output is correct
30 Correct 1086 ms 45652 KB Output is correct
31 Correct 859 ms 46368 KB Output is correct
32 Correct 1061 ms 45648 KB Output is correct
33 Correct 773 ms 46240 KB Output is correct
34 Correct 797 ms 46160 KB Output is correct
35 Correct 408 ms 23640 KB Output is correct
36 Correct 408 ms 23644 KB Output is correct
37 Correct 407 ms 23644 KB Output is correct
38 Correct 272 ms 12288 KB Output is correct
39 Correct 278 ms 12120 KB Output is correct
40 Correct 905 ms 46576 KB Output is correct
41 Correct 279 ms 12124 KB Output is correct
42 Correct 914 ms 46928 KB Output is correct
43 Correct 907 ms 47060 KB Output is correct
44 Correct 802 ms 48464 KB Output is correct
45 Correct 4 ms 2908 KB Output is correct
46 Correct 896 ms 46920 KB Output is correct
47 Correct 974 ms 47696 KB Output is correct
48 Correct 868 ms 47116 KB Output is correct
49 Incorrect 1004 ms 47744 KB Output isn't correct
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3164 KB Output is correct
2 Correct 3 ms 2908 KB Output is correct
3 Correct 833 ms 45420 KB Output is correct
4 Correct 1632 ms 43088 KB Output is correct
5 Correct 1637 ms 42584 KB Output is correct
6 Correct 1165 ms 43352 KB Output is correct
7 Correct 1178 ms 43600 KB Output is correct
8 Correct 14 ms 21596 KB Output is correct
9 Correct 1 ms 1628 KB Output is correct
10 Correct 15 ms 23312 KB Output is correct
11 Correct 1633 ms 42892 KB Output is correct
12 Correct 1627 ms 42864 KB Output is correct
13 Correct 2 ms 2908 KB Output is correct
14 Correct 1575 ms 42764 KB Output is correct
15 Correct 2 ms 3160 KB Output is correct
16 Correct 1136 ms 43100 KB Output is correct
17 Correct 2 ms 3160 KB Output is correct
18 Correct 1199 ms 43600 KB Output is correct
19 Correct 14 ms 21592 KB Output is correct
20 Correct 668 ms 44552 KB Output is correct
21 Correct 635 ms 44632 KB Output is correct
22 Correct 15 ms 23128 KB Output is correct
23 Correct 807 ms 46052 KB Output is correct
24 Correct 16 ms 23132 KB Output is correct
25 Correct 821 ms 46328 KB Output is correct
26 Correct 780 ms 45380 KB Output is correct
27 Correct 781 ms 45656 KB Output is correct
28 Correct 767 ms 45196 KB Output is correct
29 Correct 769 ms 45916 KB Output is correct
30 Correct 1086 ms 45652 KB Output is correct
31 Correct 859 ms 46368 KB Output is correct
32 Correct 1061 ms 45648 KB Output is correct
33 Correct 773 ms 46240 KB Output is correct
34 Correct 797 ms 46160 KB Output is correct
35 Correct 408 ms 23640 KB Output is correct
36 Correct 408 ms 23644 KB Output is correct
37 Correct 407 ms 23644 KB Output is correct
38 Correct 272 ms 12288 KB Output is correct
39 Correct 278 ms 12120 KB Output is correct
40 Correct 905 ms 46576 KB Output is correct
41 Correct 279 ms 12124 KB Output is correct
42 Correct 914 ms 46928 KB Output is correct
43 Correct 907 ms 47060 KB Output is correct
44 Correct 4 ms 2908 KB Output is correct
45 Runtime error 240 ms 524288 KB Execution killed with signal 9
46 Halted 0 ms 0 KB -