답안 #1035450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035450 2024-07-26T11:15:49 Z vjudge1 Political Development (BOI17_politicaldevelopment) C++17
54 / 100
2228 ms 7780 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 = 5e3, X = 5e3;

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], r, taken, 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) {
  if (c++ > X) return;

  int sz = taken.count();
  if (sz > ans) {
    ans = sz;
    clean(sz+1);
  }

  shuffle(all(adj[x]), rng);
  for (int& y : adj[x]) { 
    if (c++ > X) return;
    if (r[y] || 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;
  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);
      }
    }
  }

  for (int i = 0; i < n; i++) {
    if (r[i]) continue;

    c = 0;

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

    dfs(i);
  }

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

Compilation message

politicaldevelopment.cpp: In function 'void clean(int)':
politicaldevelopment.cpp:18:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     if (adj[i].size()+1 < x) r[i] = 1;
      |         ~~~~~~~~~~~~~~~~^~~
politicaldevelopment.cpp: In function 'void dfs(int)':
politicaldevelopment.cpp:34:54: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |     if (r[y] || taken[y] || (taken & bt2[y]).count() < sz) continue;
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 6 ms 6748 KB Output is correct
4 Correct 4 ms 6748 KB Output is correct
5 Correct 4 ms 6744 KB Output is correct
6 Correct 4 ms 6784 KB Output is correct
7 Correct 5 ms 6748 KB Output is correct
8 Correct 2 ms 3676 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 6 ms 6748 KB Output is correct
4 Correct 4 ms 6748 KB Output is correct
5 Correct 4 ms 6744 KB Output is correct
6 Correct 4 ms 6784 KB Output is correct
7 Correct 5 ms 6748 KB Output is correct
8 Correct 2 ms 3676 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 3676 KB Output is correct
11 Correct 4 ms 6748 KB Output is correct
12 Correct 4 ms 6748 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 6748 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 6812 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 4 ms 6748 KB Output is correct
19 Correct 2 ms 3676 KB Output is correct
20 Correct 4 ms 6748 KB Output is correct
21 Correct 4 ms 6748 KB Output is correct
22 Correct 2 ms 3676 KB Output is correct
23 Correct 7 ms 6948 KB Output is correct
24 Correct 2 ms 3676 KB Output is correct
25 Correct 8 ms 6748 KB Output is correct
26 Correct 8 ms 6748 KB Output is correct
27 Correct 7 ms 6940 KB Output is correct
28 Correct 8 ms 6840 KB Output is correct
29 Correct 7 ms 6744 KB Output is correct
30 Correct 218 ms 6748 KB Output is correct
31 Correct 9 ms 6748 KB Output is correct
32 Correct 225 ms 6744 KB Output is correct
33 Correct 10 ms 6948 KB Output is correct
34 Correct 10 ms 6892 KB Output is correct
35 Correct 5 ms 3676 KB Output is correct
36 Correct 5 ms 3672 KB Output is correct
37 Correct 5 ms 3676 KB Output is correct
38 Correct 9 ms 2140 KB Output is correct
39 Correct 9 ms 2140 KB Output is correct
40 Correct 14 ms 6748 KB Output is correct
41 Correct 9 ms 2136 KB Output is correct
42 Correct 13 ms 6748 KB Output is correct
43 Correct 14 ms 6744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3584 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Runtime error 2 ms 1060 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 6 ms 6748 KB Output is correct
4 Correct 4 ms 6748 KB Output is correct
5 Correct 4 ms 6744 KB Output is correct
6 Correct 4 ms 6784 KB Output is correct
7 Correct 5 ms 6748 KB Output is correct
8 Correct 2 ms 3676 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 3676 KB Output is correct
11 Correct 4 ms 6748 KB Output is correct
12 Correct 4 ms 6748 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 6748 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 6812 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 4 ms 6748 KB Output is correct
19 Correct 2 ms 3676 KB Output is correct
20 Correct 4 ms 6748 KB Output is correct
21 Correct 4 ms 6748 KB Output is correct
22 Correct 2 ms 3676 KB Output is correct
23 Correct 7 ms 6948 KB Output is correct
24 Correct 2 ms 3676 KB Output is correct
25 Correct 8 ms 6748 KB Output is correct
26 Correct 8 ms 6748 KB Output is correct
27 Correct 7 ms 6940 KB Output is correct
28 Correct 8 ms 6840 KB Output is correct
29 Correct 7 ms 6744 KB Output is correct
30 Correct 218 ms 6748 KB Output is correct
31 Correct 9 ms 6748 KB Output is correct
32 Correct 225 ms 6744 KB Output is correct
33 Correct 10 ms 6948 KB Output is correct
34 Correct 10 ms 6892 KB Output is correct
35 Correct 5 ms 3676 KB Output is correct
36 Correct 5 ms 3672 KB Output is correct
37 Correct 5 ms 3676 KB Output is correct
38 Correct 9 ms 2140 KB Output is correct
39 Correct 9 ms 2140 KB Output is correct
40 Correct 14 ms 6748 KB Output is correct
41 Correct 9 ms 2136 KB Output is correct
42 Correct 13 ms 6748 KB Output is correct
43 Correct 14 ms 6744 KB Output is correct
44 Correct 7 ms 7004 KB Output is correct
45 Correct 0 ms 604 KB Output is correct
46 Correct 13 ms 6976 KB Output is correct
47 Correct 46 ms 7004 KB Output is correct
48 Correct 16 ms 6748 KB Output is correct
49 Correct 48 ms 7004 KB Output is correct
50 Correct 48 ms 7004 KB Output is correct
51 Correct 166 ms 7312 KB Output is correct
52 Correct 4 ms 6748 KB Output is correct
53 Correct 2165 ms 7448 KB Output is correct
54 Correct 238 ms 7780 KB Output is correct
55 Correct 4 ms 7004 KB Output is correct
56 Correct 5 ms 6908 KB Output is correct
57 Correct 2 ms 3672 KB Output is correct
58 Correct 2228 ms 7772 KB Output is correct
59 Correct 5 ms 7000 KB Output is correct
60 Correct 4 ms 7004 KB Output is correct
61 Correct 5 ms 6852 KB Output is correct
62 Correct 6 ms 7004 KB Output is correct
63 Correct 6 ms 7044 KB Output is correct
64 Correct 8 ms 7004 KB Output is correct
65 Correct 9 ms 7004 KB Output is correct
66 Correct 5 ms 7044 KB Output is correct
67 Correct 248 ms 7356 KB Output is correct
68 Correct 7 ms 7004 KB Output is correct
69 Correct 11 ms 7004 KB Output is correct
70 Correct 226 ms 7220 KB Output is correct
71 Correct 246 ms 7508 KB Output is correct
72 Correct 255 ms 7332 KB Output is correct
73 Correct 8 ms 6748 KB Output is correct
74 Correct 211 ms 7000 KB Output is correct
75 Correct 262 ms 7260 KB Output is correct
76 Correct 310 ms 7004 KB Output is correct
77 Correct 73 ms 7516 KB Output is correct
78 Correct 9 ms 7000 KB Output is correct
79 Correct 34 ms 3932 KB Output is correct
80 Correct 325 ms 7128 KB Output is correct
81 Correct 72 ms 7512 KB Output is correct
82 Correct 9 ms 2136 KB Output is correct
83 Correct 38 ms 4180 KB Output is correct
84 Correct 46 ms 7260 KB Output is correct
85 Correct 9 ms 2136 KB Output is correct
86 Correct 47 ms 7260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 6 ms 6748 KB Output is correct
4 Correct 4 ms 6748 KB Output is correct
5 Correct 4 ms 6744 KB Output is correct
6 Correct 4 ms 6784 KB Output is correct
7 Correct 5 ms 6748 KB Output is correct
8 Correct 2 ms 3676 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 3676 KB Output is correct
11 Correct 4 ms 6748 KB Output is correct
12 Correct 4 ms 6748 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 3 ms 6748 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 4 ms 6812 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 4 ms 6748 KB Output is correct
19 Correct 2 ms 3676 KB Output is correct
20 Correct 4 ms 6748 KB Output is correct
21 Correct 4 ms 6748 KB Output is correct
22 Correct 2 ms 3676 KB Output is correct
23 Correct 7 ms 6948 KB Output is correct
24 Correct 2 ms 3676 KB Output is correct
25 Correct 8 ms 6748 KB Output is correct
26 Correct 8 ms 6748 KB Output is correct
27 Correct 7 ms 6940 KB Output is correct
28 Correct 8 ms 6840 KB Output is correct
29 Correct 7 ms 6744 KB Output is correct
30 Correct 218 ms 6748 KB Output is correct
31 Correct 9 ms 6748 KB Output is correct
32 Correct 225 ms 6744 KB Output is correct
33 Correct 10 ms 6948 KB Output is correct
34 Correct 10 ms 6892 KB Output is correct
35 Correct 5 ms 3676 KB Output is correct
36 Correct 5 ms 3672 KB Output is correct
37 Correct 5 ms 3676 KB Output is correct
38 Correct 9 ms 2140 KB Output is correct
39 Correct 9 ms 2140 KB Output is correct
40 Correct 14 ms 6748 KB Output is correct
41 Correct 9 ms 2136 KB Output is correct
42 Correct 13 ms 6748 KB Output is correct
43 Correct 14 ms 6744 KB Output is correct
44 Correct 0 ms 600 KB Output is correct
45 Runtime error 1 ms 1116 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -