답안 #1117555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1117555 2024-11-24T00:40:09 Z stefanneagu Political Development (BOI17_politicaldevelopment) C++17
100 / 100
711 ms 333672 KB
#include <bits/stdc++.h>

using namespace std;

const int nmax = 5e4 + 2;

set<int> adj[nmax];
bitset<nmax> f[nmax];
int ans = 0;

void calc(int i) {
  for(int bit = 0; bit < (1 << adj[i].size()); bit++) {
    vector<int> v;
    auto pl = adj[i].begin();
    for(int x = 0; (1 << x) <= bit; x++) {
      if(bit & (1 << x)) {
        v.push_back(*pl);
      }
      pl++;
    }
    v.push_back(i);
    bool ok = 1;
    for(auto it : v) {
      for(auto it2 : v) {
        if(it != it2 && f[it][it2] == 0) {
          ok = 0;
          break;
        }
      }
      if(!ok) {
        break;
      }
    }
    if(ok) {
      ans = max(ans, (int) v.size());
    }
  }
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  for(int i = 1; i <= n; i++) {
    int d;
    cin >> d;
    while(d--) {
      int j;
      cin >> j;
      j++;
      adj[i].insert(j);
      f[i][j] = 1;
    }
  }
  set<pair<int, int>> noduri;
  for(int i = 1; i <= n; i++) {
    noduri.insert({adj[i].size(), i});
  }
  for(int _ = 1; _ <= n; _++) {
    pair<int, int> top = *noduri.begin();
    int i = top.second;
    calc(i);
    // cout << i << " ";
    noduri.erase({adj[i].size(), i});
    for(auto it : adj[i]) {
      noduri.erase({adj[it].size(), it});
      adj[it].erase(i);
      noduri.insert({adj[it].size(), it});
    }
  }
  cout << ans;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2896 KB Output is correct
2 Correct 2 ms 2896 KB Output is correct
3 Correct 8 ms 34384 KB Output is correct
4 Correct 8 ms 34384 KB Output is correct
5 Correct 8 ms 34544 KB Output is correct
6 Correct 11 ms 34384 KB Output is correct
7 Correct 9 ms 34396 KB Output is correct
8 Correct 3 ms 3152 KB Output is correct
9 Correct 1 ms 2896 KB Output is correct
10 Correct 3 ms 7248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2896 KB Output is correct
2 Correct 2 ms 2896 KB Output is correct
3 Correct 8 ms 34384 KB Output is correct
4 Correct 8 ms 34384 KB Output is correct
5 Correct 8 ms 34544 KB Output is correct
6 Correct 11 ms 34384 KB Output is correct
7 Correct 9 ms 34396 KB Output is correct
8 Correct 3 ms 3152 KB Output is correct
9 Correct 1 ms 2896 KB Output is correct
10 Correct 3 ms 7248 KB Output is correct
11 Correct 8 ms 34552 KB Output is correct
12 Correct 8 ms 34552 KB Output is correct
13 Correct 2 ms 2896 KB Output is correct
14 Correct 8 ms 34384 KB Output is correct
15 Correct 1 ms 2896 KB Output is correct
16 Correct 8 ms 34396 KB Output is correct
17 Correct 1 ms 2740 KB Output is correct
18 Correct 10 ms 34384 KB Output is correct
19 Correct 3 ms 3152 KB Output is correct
20 Correct 7 ms 34300 KB Output is correct
21 Correct 6 ms 34236 KB Output is correct
22 Correct 3 ms 7248 KB Output is correct
23 Correct 10 ms 34640 KB Output is correct
24 Correct 3 ms 7248 KB Output is correct
25 Correct 10 ms 34832 KB Output is correct
26 Correct 9 ms 34384 KB Output is correct
27 Correct 8 ms 34572 KB Output is correct
28 Correct 9 ms 34384 KB Output is correct
29 Correct 8 ms 34384 KB Output is correct
30 Correct 10 ms 34640 KB Output is correct
31 Correct 10 ms 34808 KB Output is correct
32 Correct 11 ms 34640 KB Output is correct
33 Correct 10 ms 34652 KB Output is correct
34 Correct 10 ms 34640 KB Output is correct
35 Correct 6 ms 19792 KB Output is correct
36 Correct 5 ms 19792 KB Output is correct
37 Correct 6 ms 19792 KB Output is correct
38 Correct 4 ms 11572 KB Output is correct
39 Correct 4 ms 11344 KB Output is correct
40 Correct 13 ms 34896 KB Output is correct
41 Correct 4 ms 11344 KB Output is correct
42 Correct 13 ms 34896 KB Output is correct
43 Correct 13 ms 34896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3152 KB Output is correct
2 Correct 2 ms 2896 KB Output is correct
3 Correct 1 ms 2896 KB Output is correct
4 Correct 1 ms 2896 KB Output is correct
5 Correct 1 ms 2896 KB Output is correct
6 Correct 1 ms 2896 KB Output is correct
7 Correct 1 ms 2896 KB Output is correct
8 Correct 1 ms 2896 KB Output is correct
9 Correct 1 ms 2896 KB Output is correct
10 Correct 1 ms 2896 KB Output is correct
11 Correct 608 ms 332276 KB Output is correct
12 Correct 2 ms 2896 KB Output is correct
13 Correct 711 ms 332184 KB Output is correct
14 Correct 1 ms 2896 KB Output is correct
15 Correct 674 ms 332204 KB Output is correct
16 Correct 666 ms 332284 KB Output is correct
17 Correct 600 ms 333672 KB Output is correct
18 Correct 575 ms 333640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2896 KB Output is correct
2 Correct 2 ms 2896 KB Output is correct
3 Correct 8 ms 34384 KB Output is correct
4 Correct 8 ms 34384 KB Output is correct
5 Correct 8 ms 34544 KB Output is correct
6 Correct 11 ms 34384 KB Output is correct
7 Correct 9 ms 34396 KB Output is correct
8 Correct 3 ms 3152 KB Output is correct
9 Correct 1 ms 2896 KB Output is correct
10 Correct 3 ms 7248 KB Output is correct
11 Correct 8 ms 34552 KB Output is correct
12 Correct 8 ms 34552 KB Output is correct
13 Correct 2 ms 2896 KB Output is correct
14 Correct 8 ms 34384 KB Output is correct
15 Correct 1 ms 2896 KB Output is correct
16 Correct 8 ms 34396 KB Output is correct
17 Correct 1 ms 2740 KB Output is correct
18 Correct 10 ms 34384 KB Output is correct
19 Correct 3 ms 3152 KB Output is correct
20 Correct 7 ms 34300 KB Output is correct
21 Correct 6 ms 34236 KB Output is correct
22 Correct 3 ms 7248 KB Output is correct
23 Correct 10 ms 34640 KB Output is correct
24 Correct 3 ms 7248 KB Output is correct
25 Correct 10 ms 34832 KB Output is correct
26 Correct 9 ms 34384 KB Output is correct
27 Correct 8 ms 34572 KB Output is correct
28 Correct 9 ms 34384 KB Output is correct
29 Correct 8 ms 34384 KB Output is correct
30 Correct 10 ms 34640 KB Output is correct
31 Correct 10 ms 34808 KB Output is correct
32 Correct 11 ms 34640 KB Output is correct
33 Correct 10 ms 34652 KB Output is correct
34 Correct 10 ms 34640 KB Output is correct
35 Correct 6 ms 19792 KB Output is correct
36 Correct 5 ms 19792 KB Output is correct
37 Correct 6 ms 19792 KB Output is correct
38 Correct 4 ms 11572 KB Output is correct
39 Correct 4 ms 11344 KB Output is correct
40 Correct 13 ms 34896 KB Output is correct
41 Correct 4 ms 11344 KB Output is correct
42 Correct 13 ms 34896 KB Output is correct
43 Correct 13 ms 34896 KB Output is correct
44 Correct 49 ms 36176 KB Output is correct
45 Correct 2 ms 2896 KB Output is correct
46 Correct 12 ms 34980 KB Output is correct
47 Correct 24 ms 36188 KB Output is correct
48 Correct 12 ms 34896 KB Output is correct
49 Correct 25 ms 36188 KB Output is correct
50 Correct 25 ms 35920 KB Output is correct
51 Correct 194 ms 37712 KB Output is correct
52 Correct 9 ms 34384 KB Output is correct
53 Correct 291 ms 38648 KB Output is correct
54 Correct 344 ms 38736 KB Output is correct
55 Correct 9 ms 34384 KB Output is correct
56 Correct 9 ms 34384 KB Output is correct
57 Correct 3 ms 3404 KB Output is correct
58 Correct 286 ms 38736 KB Output is correct
59 Correct 15 ms 35152 KB Output is correct
60 Correct 9 ms 34384 KB Output is correct
61 Correct 13 ms 34896 KB Output is correct
62 Correct 13 ms 34896 KB Output is correct
63 Correct 52 ms 36192 KB Output is correct
64 Correct 33 ms 35920 KB Output is correct
65 Correct 13 ms 34896 KB Output is correct
66 Correct 12 ms 35152 KB Output is correct
67 Correct 46 ms 36432 KB Output is correct
68 Correct 32 ms 35672 KB Output is correct
69 Correct 12 ms 34896 KB Output is correct
70 Correct 23 ms 35920 KB Output is correct
71 Correct 45 ms 36432 KB Output is correct
72 Correct 36 ms 36432 KB Output is correct
73 Correct 8 ms 34640 KB Output is correct
74 Correct 22 ms 35920 KB Output is correct
75 Correct 39 ms 36432 KB Output is correct
76 Correct 16 ms 35408 KB Output is correct
77 Correct 84 ms 37072 KB Output is correct
78 Correct 8 ms 34384 KB Output is correct
79 Correct 35 ms 21072 KB Output is correct
80 Correct 16 ms 35408 KB Output is correct
81 Correct 74 ms 36944 KB Output is correct
82 Correct 4 ms 11516 KB Output is correct
83 Correct 38 ms 21240 KB Output is correct
84 Correct 39 ms 36604 KB Output is correct
85 Correct 4 ms 11344 KB Output is correct
86 Correct 38 ms 36432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2896 KB Output is correct
2 Correct 2 ms 2896 KB Output is correct
3 Correct 8 ms 34384 KB Output is correct
4 Correct 8 ms 34384 KB Output is correct
5 Correct 8 ms 34544 KB Output is correct
6 Correct 11 ms 34384 KB Output is correct
7 Correct 9 ms 34396 KB Output is correct
8 Correct 3 ms 3152 KB Output is correct
9 Correct 1 ms 2896 KB Output is correct
10 Correct 3 ms 7248 KB Output is correct
11 Correct 8 ms 34552 KB Output is correct
12 Correct 8 ms 34552 KB Output is correct
13 Correct 2 ms 2896 KB Output is correct
14 Correct 8 ms 34384 KB Output is correct
15 Correct 1 ms 2896 KB Output is correct
16 Correct 8 ms 34396 KB Output is correct
17 Correct 1 ms 2740 KB Output is correct
18 Correct 10 ms 34384 KB Output is correct
19 Correct 3 ms 3152 KB Output is correct
20 Correct 7 ms 34300 KB Output is correct
21 Correct 6 ms 34236 KB Output is correct
22 Correct 3 ms 7248 KB Output is correct
23 Correct 10 ms 34640 KB Output is correct
24 Correct 3 ms 7248 KB Output is correct
25 Correct 10 ms 34832 KB Output is correct
26 Correct 9 ms 34384 KB Output is correct
27 Correct 8 ms 34572 KB Output is correct
28 Correct 9 ms 34384 KB Output is correct
29 Correct 8 ms 34384 KB Output is correct
30 Correct 10 ms 34640 KB Output is correct
31 Correct 10 ms 34808 KB Output is correct
32 Correct 11 ms 34640 KB Output is correct
33 Correct 10 ms 34652 KB Output is correct
34 Correct 10 ms 34640 KB Output is correct
35 Correct 6 ms 19792 KB Output is correct
36 Correct 5 ms 19792 KB Output is correct
37 Correct 6 ms 19792 KB Output is correct
38 Correct 4 ms 11572 KB Output is correct
39 Correct 4 ms 11344 KB Output is correct
40 Correct 13 ms 34896 KB Output is correct
41 Correct 4 ms 11344 KB Output is correct
42 Correct 13 ms 34896 KB Output is correct
43 Correct 13 ms 34896 KB Output is correct
44 Correct 1 ms 2896 KB Output is correct
45 Correct 380 ms 321792 KB Output is correct
46 Correct 221 ms 293960 KB Output is correct
47 Correct 350 ms 322376 KB Output is correct
48 Correct 369 ms 322888 KB Output is correct
49 Correct 154 ms 242388 KB Output is correct
50 Correct 360 ms 332220 KB Output is correct
51 Correct 390 ms 322432 KB Output is correct
52 Correct 148 ms 232264 KB Output is correct
53 Correct 152 ms 242760 KB Output is correct
54 Correct 13 ms 5196 KB Output is correct
55 Correct 371 ms 332356 KB Output is correct
56 Correct 128 ms 224396 KB Output is correct
57 Correct 155 ms 227880 KB Output is correct
58 Correct 198 ms 304412 KB Output is correct
59 Correct 124 ms 227712 KB Output is correct
60 Correct 119 ms 225792 KB Output is correct
61 Correct 194 ms 304468 KB Output is correct
62 Correct 162 ms 281416 KB Output is correct
63 Correct 230 ms 301652 KB Output is correct
64 Correct 117 ms 224812 KB Output is correct
65 Correct 278 ms 310792 KB Output is correct
66 Correct 170 ms 281624 KB Output is correct
67 Correct 251 ms 301640 KB Output is correct
68 Correct 286 ms 309320 KB Output is correct
69 Correct 301 ms 312032 KB Output is correct
70 Correct 200 ms 282440 KB Output is correct
71 Correct 278 ms 310268 KB Output is correct
72 Correct 250 ms 295240 KB Output is correct
73 Correct 312 ms 321684 KB Output is correct
74 Correct 176 ms 283192 KB Output is correct
75 Correct 99 ms 156324 KB Output is correct
76 Correct 216 ms 290120 KB Output is correct
77 Correct 319 ms 321864 KB Output is correct
78 Correct 122 ms 160148 KB Output is correct
79 Correct 117 ms 155976 KB Output is correct
80 Correct 32 ms 80712 KB Output is correct
81 Correct 137 ms 159420 KB Output is correct
82 Correct 299 ms 314572 KB Output is correct
83 Correct 35 ms 80208 KB Output is correct
84 Correct 283 ms 315464 KB Output is correct