답안 #1035487

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035487 2024-07-26T11:31:42 Z vjudge1 Political Development (BOI17_politicaldevelopment) C++17
39 / 100
3000 ms 335612 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 = 1e3/*, X2 = 1e3*/;

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> 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 dfs2(int x) {
  if (c++ > X2) 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++ > X2) return;
    if (r[y] || 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();
  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;
      st[i].insert(y);

      if (st[y].find(i) != st[y].end()) {
        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);
    //if (n <= 5000) dfs(i);
    //else dfs2(i);

    r[i] = 1;
  }

  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;
      |         ~~~~~~~~~~~~~~~~^~~
politicaldevelopment.cpp: In function 'void dfs(int)':
politicaldevelopment.cpp:63:54: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   63 |     if (r[y] || taken[y] || (taken & bt2[y]).count() < sz) continue;
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4188 KB Output is correct
2 Correct 2 ms 3932 KB Output is correct
3 Correct 19 ms 25948 KB Output is correct
4 Correct 13 ms 25432 KB Output is correct
5 Correct 12 ms 25436 KB Output is correct
6 Correct 13 ms 25692 KB Output is correct
7 Correct 12 ms 25948 KB Output is correct
8 Correct 14 ms 24244 KB Output is correct
9 Correct 1 ms 3932 KB Output is correct
10 Correct 10 ms 23900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4188 KB Output is correct
2 Correct 2 ms 3932 KB Output is correct
3 Correct 19 ms 25948 KB Output is correct
4 Correct 13 ms 25432 KB Output is correct
5 Correct 12 ms 25436 KB Output is correct
6 Correct 13 ms 25692 KB Output is correct
7 Correct 12 ms 25948 KB Output is correct
8 Correct 14 ms 24244 KB Output is correct
9 Correct 1 ms 3932 KB Output is correct
10 Correct 10 ms 23900 KB Output is correct
11 Correct 13 ms 25608 KB Output is correct
12 Correct 12 ms 25448 KB Output is correct
13 Correct 2 ms 3932 KB Output is correct
14 Correct 14 ms 25436 KB Output is correct
15 Correct 2 ms 3932 KB Output is correct
16 Correct 14 ms 25776 KB Output is correct
17 Correct 2 ms 4188 KB Output is correct
18 Correct 14 ms 25944 KB Output is correct
19 Correct 13 ms 24156 KB Output is correct
20 Correct 9 ms 25632 KB Output is correct
21 Correct 10 ms 25692 KB Output is correct
22 Correct 9 ms 24156 KB Output is correct
23 Correct 20 ms 26612 KB Output is correct
24 Correct 9 ms 24156 KB Output is correct
25 Correct 25 ms 26500 KB Output is correct
26 Correct 27 ms 26204 KB Output is correct
27 Correct 24 ms 26204 KB Output is correct
28 Correct 23 ms 26204 KB Output is correct
29 Correct 27 ms 26360 KB Output is correct
30 Correct 240 ms 26480 KB Output is correct
31 Correct 34 ms 26712 KB Output is correct
32 Correct 182 ms 26584 KB Output is correct
33 Correct 30 ms 26716 KB Output is correct
34 Correct 32 ms 26460 KB Output is correct
35 Correct 15 ms 14940 KB Output is correct
36 Correct 14 ms 14940 KB Output is correct
37 Correct 15 ms 15056 KB Output is correct
38 Correct 22 ms 9532 KB Output is correct
39 Correct 23 ms 9304 KB Output is correct
40 Correct 35 ms 27224 KB Output is correct
41 Correct 23 ms 9304 KB Output is correct
42 Correct 39 ms 27228 KB Output is correct
43 Correct 38 ms 27224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 24152 KB Output is correct
2 Correct 2 ms 4188 KB Output is correct
3 Correct 2 ms 4188 KB Output is correct
4 Correct 1 ms 4188 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 3932 KB Output is correct
9 Correct 2 ms 3932 KB Output is correct
10 Correct 2 ms 3932 KB Output is correct
11 Correct 1779 ms 335608 KB Output is correct
12 Correct 2 ms 4188 KB Output is correct
13 Correct 1752 ms 335600 KB Output is correct
14 Correct 2 ms 3928 KB Output is correct
15 Correct 1723 ms 335440 KB Output is correct
16 Correct 1826 ms 335432 KB Output is correct
17 Correct 1958 ms 335444 KB Output is correct
18 Correct 1964 ms 335612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4188 KB Output is correct
2 Correct 2 ms 3932 KB Output is correct
3 Correct 19 ms 25948 KB Output is correct
4 Correct 13 ms 25432 KB Output is correct
5 Correct 12 ms 25436 KB Output is correct
6 Correct 13 ms 25692 KB Output is correct
7 Correct 12 ms 25948 KB Output is correct
8 Correct 14 ms 24244 KB Output is correct
9 Correct 1 ms 3932 KB Output is correct
10 Correct 10 ms 23900 KB Output is correct
11 Correct 13 ms 25608 KB Output is correct
12 Correct 12 ms 25448 KB Output is correct
13 Correct 2 ms 3932 KB Output is correct
14 Correct 14 ms 25436 KB Output is correct
15 Correct 2 ms 3932 KB Output is correct
16 Correct 14 ms 25776 KB Output is correct
17 Correct 2 ms 4188 KB Output is correct
18 Correct 14 ms 25944 KB Output is correct
19 Correct 13 ms 24156 KB Output is correct
20 Correct 9 ms 25632 KB Output is correct
21 Correct 10 ms 25692 KB Output is correct
22 Correct 9 ms 24156 KB Output is correct
23 Correct 20 ms 26612 KB Output is correct
24 Correct 9 ms 24156 KB Output is correct
25 Correct 25 ms 26500 KB Output is correct
26 Correct 27 ms 26204 KB Output is correct
27 Correct 24 ms 26204 KB Output is correct
28 Correct 23 ms 26204 KB Output is correct
29 Correct 27 ms 26360 KB Output is correct
30 Correct 240 ms 26480 KB Output is correct
31 Correct 34 ms 26712 KB Output is correct
32 Correct 182 ms 26584 KB Output is correct
33 Correct 30 ms 26716 KB Output is correct
34 Correct 32 ms 26460 KB Output is correct
35 Correct 15 ms 14940 KB Output is correct
36 Correct 14 ms 14940 KB Output is correct
37 Correct 15 ms 15056 KB Output is correct
38 Correct 22 ms 9532 KB Output is correct
39 Correct 23 ms 9304 KB Output is correct
40 Correct 35 ms 27224 KB Output is correct
41 Correct 23 ms 9304 KB Output is correct
42 Correct 39 ms 27228 KB Output is correct
43 Correct 38 ms 27224 KB Output is correct
44 Correct 26 ms 28508 KB Output is correct
45 Correct 3 ms 3932 KB Output is correct
46 Correct 36 ms 27108 KB Output is correct
47 Correct 120 ms 28624 KB Output is correct
48 Correct 43 ms 26968 KB Output is correct
49 Correct 111 ms 28776 KB Output is correct
50 Correct 114 ms 28508 KB Output is correct
51 Incorrect 450 ms 31188 KB Output isn't correct
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4188 KB Output is correct
2 Correct 2 ms 3932 KB Output is correct
3 Correct 19 ms 25948 KB Output is correct
4 Correct 13 ms 25432 KB Output is correct
5 Correct 12 ms 25436 KB Output is correct
6 Correct 13 ms 25692 KB Output is correct
7 Correct 12 ms 25948 KB Output is correct
8 Correct 14 ms 24244 KB Output is correct
9 Correct 1 ms 3932 KB Output is correct
10 Correct 10 ms 23900 KB Output is correct
11 Correct 13 ms 25608 KB Output is correct
12 Correct 12 ms 25448 KB Output is correct
13 Correct 2 ms 3932 KB Output is correct
14 Correct 14 ms 25436 KB Output is correct
15 Correct 2 ms 3932 KB Output is correct
16 Correct 14 ms 25776 KB Output is correct
17 Correct 2 ms 4188 KB Output is correct
18 Correct 14 ms 25944 KB Output is correct
19 Correct 13 ms 24156 KB Output is correct
20 Correct 9 ms 25632 KB Output is correct
21 Correct 10 ms 25692 KB Output is correct
22 Correct 9 ms 24156 KB Output is correct
23 Correct 20 ms 26612 KB Output is correct
24 Correct 9 ms 24156 KB Output is correct
25 Correct 25 ms 26500 KB Output is correct
26 Correct 27 ms 26204 KB Output is correct
27 Correct 24 ms 26204 KB Output is correct
28 Correct 23 ms 26204 KB Output is correct
29 Correct 27 ms 26360 KB Output is correct
30 Correct 240 ms 26480 KB Output is correct
31 Correct 34 ms 26712 KB Output is correct
32 Correct 182 ms 26584 KB Output is correct
33 Correct 30 ms 26716 KB Output is correct
34 Correct 32 ms 26460 KB Output is correct
35 Correct 15 ms 14940 KB Output is correct
36 Correct 14 ms 14940 KB Output is correct
37 Correct 15 ms 15056 KB Output is correct
38 Correct 22 ms 9532 KB Output is correct
39 Correct 23 ms 9304 KB Output is correct
40 Correct 35 ms 27224 KB Output is correct
41 Correct 23 ms 9304 KB Output is correct
42 Correct 39 ms 27228 KB Output is correct
43 Correct 38 ms 27224 KB Output is correct
44 Correct 1 ms 4184 KB Output is correct
45 Correct 1000 ms 324628 KB Output is correct
46 Correct 243 ms 307280 KB Output is correct
47 Correct 899 ms 324436 KB Output is correct
48 Correct 856 ms 325932 KB Output is correct
49 Correct 139 ms 280540 KB Output is correct
50 Execution timed out 3075 ms 332788 KB Time limit exceeded
51 Halted 0 ms 0 KB -