답안 #1035440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035440 2024-07-26T11:07:46 Z vjudge1 Political Development (BOI17_politicaldevelopment) C++17
16 / 100
2594 ms 8804 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], taken, toTake;

void dfs2(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];

    dfs2(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++) {
    c = 0;

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

    dfs2(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;
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2136 KB Output is correct
2 Correct 3 ms 2140 KB Output is correct
3 Correct 1204 ms 8544 KB Output is correct
4 Correct 2404 ms 6952 KB Output is correct
5 Correct 2312 ms 6944 KB Output is correct
6 Correct 1816 ms 7000 KB Output is correct
7 Correct 1839 ms 7168 KB Output is correct
8 Correct 2 ms 3672 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 3 ms 5468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2136 KB Output is correct
2 Correct 3 ms 2140 KB Output is correct
3 Correct 1204 ms 8544 KB Output is correct
4 Correct 2404 ms 6952 KB Output is correct
5 Correct 2312 ms 6944 KB Output is correct
6 Correct 1816 ms 7000 KB Output is correct
7 Correct 1839 ms 7168 KB Output is correct
8 Correct 2 ms 3672 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 3 ms 5468 KB Output is correct
11 Correct 2594 ms 6944 KB Output is correct
12 Correct 2399 ms 6992 KB Output is correct
13 Correct 3 ms 1880 KB Output is correct
14 Correct 2459 ms 6944 KB Output is correct
15 Correct 2 ms 2136 KB Output is correct
16 Correct 1788 ms 7160 KB Output is correct
17 Correct 2 ms 2136 KB Output is correct
18 Correct 1732 ms 7168 KB Output is correct
19 Correct 2 ms 3676 KB Output is correct
20 Correct 928 ms 8732 KB Output is correct
21 Correct 930 ms 8540 KB Output is correct
22 Correct 3 ms 5468 KB Output is correct
23 Correct 1222 ms 8528 KB Output is correct
24 Correct 3 ms 5464 KB Output is correct
25 Correct 1286 ms 8540 KB Output is correct
26 Correct 1123 ms 8536 KB Output is correct
27 Correct 1178 ms 8364 KB Output is correct
28 Correct 1162 ms 8532 KB Output is correct
29 Correct 1121 ms 8284 KB Output is correct
30 Correct 1512 ms 8384 KB Output is correct
31 Correct 1188 ms 8284 KB Output is correct
32 Correct 1641 ms 8388 KB Output is correct
33 Correct 1206 ms 8280 KB Output is correct
34 Correct 1252 ms 8364 KB Output is correct
35 Correct 631 ms 5212 KB Output is correct
36 Correct 684 ms 5208 KB Output is correct
37 Correct 676 ms 5212 KB Output is correct
38 Correct 450 ms 2596 KB Output is correct
39 Correct 453 ms 2392 KB Output is correct
40 Correct 1324 ms 8272 KB Output is correct
41 Correct 432 ms 2624 KB Output is correct
42 Correct 1325 ms 8284 KB Output is correct
43 Correct 1336 ms 8280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3672 KB Output is correct
2 Correct 7 ms 1624 KB Output is correct
3 Correct 7 ms 1640 KB Output is correct
4 Correct 5 ms 2152 KB Output is correct
5 Correct 7 ms 2140 KB Output is correct
6 Correct 7 ms 2140 KB Output is correct
7 Correct 7 ms 2140 KB Output is correct
8 Correct 7 ms 1884 KB Output is correct
9 Correct 7 ms 2140 KB Output is correct
10 Correct 7 ms 1884 KB Output is correct
11 Runtime error 1 ms 1116 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2136 KB Output is correct
2 Correct 3 ms 2140 KB Output is correct
3 Correct 1204 ms 8544 KB Output is correct
4 Correct 2404 ms 6952 KB Output is correct
5 Correct 2312 ms 6944 KB Output is correct
6 Correct 1816 ms 7000 KB Output is correct
7 Correct 1839 ms 7168 KB Output is correct
8 Correct 2 ms 3672 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 3 ms 5468 KB Output is correct
11 Correct 2594 ms 6944 KB Output is correct
12 Correct 2399 ms 6992 KB Output is correct
13 Correct 3 ms 1880 KB Output is correct
14 Correct 2459 ms 6944 KB Output is correct
15 Correct 2 ms 2136 KB Output is correct
16 Correct 1788 ms 7160 KB Output is correct
17 Correct 2 ms 2136 KB Output is correct
18 Correct 1732 ms 7168 KB Output is correct
19 Correct 2 ms 3676 KB Output is correct
20 Correct 928 ms 8732 KB Output is correct
21 Correct 930 ms 8540 KB Output is correct
22 Correct 3 ms 5468 KB Output is correct
23 Correct 1222 ms 8528 KB Output is correct
24 Correct 3 ms 5464 KB Output is correct
25 Correct 1286 ms 8540 KB Output is correct
26 Correct 1123 ms 8536 KB Output is correct
27 Correct 1178 ms 8364 KB Output is correct
28 Correct 1162 ms 8532 KB Output is correct
29 Correct 1121 ms 8284 KB Output is correct
30 Correct 1512 ms 8384 KB Output is correct
31 Correct 1188 ms 8284 KB Output is correct
32 Correct 1641 ms 8388 KB Output is correct
33 Correct 1206 ms 8280 KB Output is correct
34 Correct 1252 ms 8364 KB Output is correct
35 Correct 631 ms 5212 KB Output is correct
36 Correct 684 ms 5208 KB Output is correct
37 Correct 676 ms 5212 KB Output is correct
38 Correct 450 ms 2596 KB Output is correct
39 Correct 453 ms 2392 KB Output is correct
40 Correct 1324 ms 8272 KB Output is correct
41 Correct 432 ms 2624 KB Output is correct
42 Correct 1325 ms 8284 KB Output is correct
43 Correct 1336 ms 8280 KB Output is correct
44 Correct 1851 ms 8804 KB Output is correct
45 Correct 5 ms 2136 KB Output is correct
46 Correct 1335 ms 8540 KB Output is correct
47 Correct 1495 ms 8188 KB Output is correct
48 Correct 1323 ms 8560 KB Output is correct
49 Correct 1669 ms 8024 KB Output is correct
50 Correct 1596 ms 8784 KB Output is correct
51 Incorrect 1770 ms 8532 KB Output isn't correct
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2136 KB Output is correct
2 Correct 3 ms 2140 KB Output is correct
3 Correct 1204 ms 8544 KB Output is correct
4 Correct 2404 ms 6952 KB Output is correct
5 Correct 2312 ms 6944 KB Output is correct
6 Correct 1816 ms 7000 KB Output is correct
7 Correct 1839 ms 7168 KB Output is correct
8 Correct 2 ms 3672 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 3 ms 5468 KB Output is correct
11 Correct 2594 ms 6944 KB Output is correct
12 Correct 2399 ms 6992 KB Output is correct
13 Correct 3 ms 1880 KB Output is correct
14 Correct 2459 ms 6944 KB Output is correct
15 Correct 2 ms 2136 KB Output is correct
16 Correct 1788 ms 7160 KB Output is correct
17 Correct 2 ms 2136 KB Output is correct
18 Correct 1732 ms 7168 KB Output is correct
19 Correct 2 ms 3676 KB Output is correct
20 Correct 928 ms 8732 KB Output is correct
21 Correct 930 ms 8540 KB Output is correct
22 Correct 3 ms 5468 KB Output is correct
23 Correct 1222 ms 8528 KB Output is correct
24 Correct 3 ms 5464 KB Output is correct
25 Correct 1286 ms 8540 KB Output is correct
26 Correct 1123 ms 8536 KB Output is correct
27 Correct 1178 ms 8364 KB Output is correct
28 Correct 1162 ms 8532 KB Output is correct
29 Correct 1121 ms 8284 KB Output is correct
30 Correct 1512 ms 8384 KB Output is correct
31 Correct 1188 ms 8284 KB Output is correct
32 Correct 1641 ms 8388 KB Output is correct
33 Correct 1206 ms 8280 KB Output is correct
34 Correct 1252 ms 8364 KB Output is correct
35 Correct 631 ms 5212 KB Output is correct
36 Correct 684 ms 5208 KB Output is correct
37 Correct 676 ms 5212 KB Output is correct
38 Correct 450 ms 2596 KB Output is correct
39 Correct 453 ms 2392 KB Output is correct
40 Correct 1324 ms 8272 KB Output is correct
41 Correct 432 ms 2624 KB Output is correct
42 Correct 1325 ms 8284 KB Output is correct
43 Correct 1336 ms 8280 KB Output is correct
44 Correct 5 ms 2136 KB Output is correct
45 Runtime error 1 ms 1116 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -