Submission #1115915

# Submission time Handle Problem Language Result Execution time Memory
1115915 2024-11-21T04:09:50 Z kustizus Political Development (BOI17_politicaldevelopment) C++17
62 / 100
2349 ms 524288 KB
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read_input(file) if (fopen(file".inp", "r")) freopen(file".inp", "r", stdin);
#define file(file) freopen (file".inp", "r", stdin); freopen (file".out", "w", stdout);

const int N = 5e4;
int n, k;
bitset <N + 5> g[N + 5];
vector <vector<int>> c[11];

void solve(){
	cin >> n >> k;
	for (int i = 0; i < n; ++i){
		int d;
		cin >> d;
		while (d--){
			int x;
			cin >> x;
			g[i][x] = 1;
		}
		c[1].push_back({i});
	}
	bitset <N + 5> b;
	int pos = 1;
	while (true){
		for (vector <int> v : c[pos]){
			bool ok = false;
			for (int x : v){
				if (!ok){
					ok = true;
					b = g[x];
				}
				else b &= g[x]; 
			}
			for (int j = b._Find_first(); j < n; j = b._Find_next(j)){
				vector <int> nxt = v;
				nxt.push_back(j);
				c[pos + 1].push_back(nxt);
			}
		}
		++pos;
		if (c[pos].empty()) break;
	}
	--pos;
	cout << pos;
}

signed main(){
    faster;
    // file("file");
    read_input("file");
    int tt = 1;
    // cin >> tt;
    while (tt--){
        solve();
    }
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:10:61: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 | #define read_input(file) if (fopen(file".inp", "r")) freopen(file".inp", "r", stdin);
      |                                                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:58:5: note: in expansion of macro 'read_input'
   58 |     read_input("file");
      |     ^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 34 ms 25424 KB Output is correct
4 Correct 19 ms 32140 KB Output is correct
5 Correct 26 ms 21328 KB Output is correct
6 Correct 16 ms 32140 KB Output is correct
7 Correct 39 ms 21408 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 5 ms 848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 34 ms 25424 KB Output is correct
4 Correct 19 ms 32140 KB Output is correct
5 Correct 26 ms 21328 KB Output is correct
6 Correct 16 ms 32140 KB Output is correct
7 Correct 39 ms 21408 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 5 ms 848 KB Output is correct
11 Correct 16 ms 32132 KB Output is correct
12 Correct 37 ms 21452 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 27 ms 21328 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 16 ms 32276 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 16 ms 32140 KB Output is correct
19 Correct 4 ms 848 KB Output is correct
20 Correct 12 ms 31740 KB Output is correct
21 Correct 15 ms 31824 KB Output is correct
22 Correct 3 ms 5124 KB Output is correct
23 Correct 19 ms 32140 KB Output is correct
24 Correct 4 ms 4944 KB Output is correct
25 Correct 21 ms 32140 KB Output is correct
26 Correct 24 ms 32156 KB Output is correct
27 Correct 28 ms 22412 KB Output is correct
28 Correct 29 ms 21756 KB Output is correct
29 Correct 23 ms 32140 KB Output is correct
30 Correct 18 ms 32140 KB Output is correct
31 Correct 22 ms 32140 KB Output is correct
32 Correct 18 ms 32140 KB Output is correct
33 Correct 17 ms 32140 KB Output is correct
34 Correct 17 ms 32140 KB Output is correct
35 Correct 13 ms 17488 KB Output is correct
36 Correct 10 ms 17332 KB Output is correct
37 Correct 8 ms 17488 KB Output is correct
38 Correct 5 ms 9040 KB Output is correct
39 Correct 5 ms 9040 KB Output is correct
40 Correct 24 ms 32908 KB Output is correct
41 Correct 5 ms 9040 KB Output is correct
42 Correct 21 ms 32804 KB Output is correct
43 Correct 23 ms 32908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 848 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 504 KB Output is correct
11 Correct 433 ms 335592 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 2349 ms 410876 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 458 ms 335512 KB Output is correct
16 Correct 645 ms 343372 KB Output is correct
17 Correct 2298 ms 410088 KB Output is correct
18 Correct 609 ms 343224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 34 ms 25424 KB Output is correct
4 Correct 19 ms 32140 KB Output is correct
5 Correct 26 ms 21328 KB Output is correct
6 Correct 16 ms 32140 KB Output is correct
7 Correct 39 ms 21408 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 5 ms 848 KB Output is correct
11 Correct 16 ms 32132 KB Output is correct
12 Correct 37 ms 21452 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 27 ms 21328 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 16 ms 32276 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 16 ms 32140 KB Output is correct
19 Correct 4 ms 848 KB Output is correct
20 Correct 12 ms 31740 KB Output is correct
21 Correct 15 ms 31824 KB Output is correct
22 Correct 3 ms 5124 KB Output is correct
23 Correct 19 ms 32140 KB Output is correct
24 Correct 4 ms 4944 KB Output is correct
25 Correct 21 ms 32140 KB Output is correct
26 Correct 24 ms 32156 KB Output is correct
27 Correct 28 ms 22412 KB Output is correct
28 Correct 29 ms 21756 KB Output is correct
29 Correct 23 ms 32140 KB Output is correct
30 Correct 18 ms 32140 KB Output is correct
31 Correct 22 ms 32140 KB Output is correct
32 Correct 18 ms 32140 KB Output is correct
33 Correct 17 ms 32140 KB Output is correct
34 Correct 17 ms 32140 KB Output is correct
35 Correct 13 ms 17488 KB Output is correct
36 Correct 10 ms 17332 KB Output is correct
37 Correct 8 ms 17488 KB Output is correct
38 Correct 5 ms 9040 KB Output is correct
39 Correct 5 ms 9040 KB Output is correct
40 Correct 24 ms 32908 KB Output is correct
41 Correct 5 ms 9040 KB Output is correct
42 Correct 21 ms 32804 KB Output is correct
43 Correct 23 ms 32908 KB Output is correct
44 Runtime error 2080 ms 524288 KB Execution killed with signal 9
45 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 34 ms 25424 KB Output is correct
4 Correct 19 ms 32140 KB Output is correct
5 Correct 26 ms 21328 KB Output is correct
6 Correct 16 ms 32140 KB Output is correct
7 Correct 39 ms 21408 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 5 ms 848 KB Output is correct
11 Correct 16 ms 32132 KB Output is correct
12 Correct 37 ms 21452 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 27 ms 21328 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 16 ms 32276 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 16 ms 32140 KB Output is correct
19 Correct 4 ms 848 KB Output is correct
20 Correct 12 ms 31740 KB Output is correct
21 Correct 15 ms 31824 KB Output is correct
22 Correct 3 ms 5124 KB Output is correct
23 Correct 19 ms 32140 KB Output is correct
24 Correct 4 ms 4944 KB Output is correct
25 Correct 21 ms 32140 KB Output is correct
26 Correct 24 ms 32156 KB Output is correct
27 Correct 28 ms 22412 KB Output is correct
28 Correct 29 ms 21756 KB Output is correct
29 Correct 23 ms 32140 KB Output is correct
30 Correct 18 ms 32140 KB Output is correct
31 Correct 22 ms 32140 KB Output is correct
32 Correct 18 ms 32140 KB Output is correct
33 Correct 17 ms 32140 KB Output is correct
34 Correct 17 ms 32140 KB Output is correct
35 Correct 13 ms 17488 KB Output is correct
36 Correct 10 ms 17332 KB Output is correct
37 Correct 8 ms 17488 KB Output is correct
38 Correct 5 ms 9040 KB Output is correct
39 Correct 5 ms 9040 KB Output is correct
40 Correct 24 ms 32908 KB Output is correct
41 Correct 5 ms 9040 KB Output is correct
42 Correct 21 ms 32804 KB Output is correct
43 Correct 23 ms 32908 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 391 ms 328692 KB Output is correct
46 Correct 290 ms 315628 KB Output is correct
47 Correct 424 ms 328520 KB Output is correct
48 Correct 337 ms 331668 KB Output is correct
49 Correct 166 ms 294660 KB Output is correct
50 Correct 386 ms 330984 KB Output is correct
51 Correct 381 ms 328432 KB Output is correct
52 Correct 186 ms 293808 KB Output is correct
53 Correct 169 ms 294664 KB Output is correct
54 Correct 22 ms 3588 KB Output is correct
55 Correct 366 ms 330984 KB Output is correct
56 Correct 124 ms 292540 KB Output is correct
57 Correct 172 ms 295416 KB Output is correct
58 Correct 895 ms 352660 KB Output is correct
59 Correct 139 ms 293628 KB Output is correct
60 Correct 132 ms 294396 KB Output is correct
61 Correct 801 ms 352444 KB Output is correct
62 Correct 272 ms 313604 KB Output is correct
63 Correct 267 ms 316396 KB Output is correct
64 Correct 120 ms 295164 KB Output is correct
65 Correct 425 ms 329024 KB Output is correct
66 Correct 274 ms 313848 KB Output is correct
67 Correct 266 ms 315884 KB Output is correct
68 Correct 309 ms 319468 KB Output is correct
69 Correct 465 ms 328940 KB Output is correct
70 Correct 187 ms 308328 KB Output is correct
71 Correct 308 ms 320532 KB Output is correct
72 Correct 220 ms 316920 KB Output is correct
73 Correct 320 ms 322976 KB Output is correct
74 Correct 158 ms 314620 KB Output is correct
75 Correct 120 ms 161532 KB Output is correct
76 Correct 212 ms 320512 KB Output is correct
77 Correct 293 ms 323308 KB Output is correct
78 Correct 147 ms 162808 KB Output is correct
79 Correct 125 ms 161532 KB Output is correct
80 Correct 55 ms 81924 KB Output is correct
81 Correct 149 ms 162808 KB Output is correct
82 Correct 258 ms 321520 KB Output is correct
83 Correct 56 ms 81924 KB Output is correct
84 Correct 249 ms 321524 KB Output is correct