Submission #1115917

# Submission time Handle Problem Language Result Execution time Memory
1115917 2024-11-21T04:12:06 Z vjudge1 Political Development (BOI17_politicaldevelopment) C++17
100 / 100
350 ms 322316 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[min(i, x)][max(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 10 ms 31824 KB Output is correct
4 Correct 7 ms 11512 KB Output is correct
5 Correct 7 ms 13392 KB Output is correct
6 Correct 9 ms 31824 KB Output is correct
7 Correct 10 ms 31984 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 3 ms 2896 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 10 ms 31824 KB Output is correct
4 Correct 7 ms 11512 KB Output is correct
5 Correct 7 ms 13392 KB Output is correct
6 Correct 9 ms 31824 KB Output is correct
7 Correct 10 ms 31984 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 3 ms 2896 KB Output is correct
11 Correct 9 ms 9296 KB Output is correct
12 Correct 7 ms 11508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 7 ms 19536 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 10 ms 31824 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 10 ms 31768 KB Output is correct
19 Correct 3 ms 848 KB Output is correct
20 Correct 8 ms 31688 KB Output is correct
21 Correct 8 ms 31568 KB Output is correct
22 Correct 3 ms 2896 KB Output is correct
23 Correct 11 ms 31824 KB Output is correct
24 Correct 3 ms 2896 KB Output is correct
25 Correct 11 ms 31824 KB Output is correct
26 Correct 10 ms 32000 KB Output is correct
27 Correct 10 ms 31760 KB Output is correct
28 Correct 11 ms 31824 KB Output is correct
29 Correct 10 ms 31824 KB Output is correct
30 Correct 14 ms 31992 KB Output is correct
31 Correct 11 ms 31824 KB Output is correct
32 Correct 15 ms 31824 KB Output is correct
33 Correct 12 ms 31824 KB Output is correct
34 Correct 11 ms 31824 KB Output is correct
35 Correct 6 ms 17232 KB Output is correct
36 Correct 6 ms 17104 KB Output is correct
37 Correct 6 ms 17232 KB Output is correct
38 Correct 4 ms 8784 KB Output is correct
39 Correct 4 ms 9032 KB Output is correct
40 Correct 16 ms 32140 KB Output is correct
41 Correct 4 ms 8784 KB Output is correct
42 Correct 15 ms 32216 KB Output is correct
43 Correct 14 ms 32140 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 508 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 336 KB Output is correct
11 Correct 308 ms 322316 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 300 ms 322288 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 305 ms 322160 KB Output is correct
16 Correct 298 ms 322292 KB Output is correct
17 Correct 313 ms 322244 KB Output is correct
18 Correct 305 ms 322292 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 10 ms 31824 KB Output is correct
4 Correct 7 ms 11512 KB Output is correct
5 Correct 7 ms 13392 KB Output is correct
6 Correct 9 ms 31824 KB Output is correct
7 Correct 10 ms 31984 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 3 ms 2896 KB Output is correct
11 Correct 9 ms 9296 KB Output is correct
12 Correct 7 ms 11508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 7 ms 19536 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 10 ms 31824 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 10 ms 31768 KB Output is correct
19 Correct 3 ms 848 KB Output is correct
20 Correct 8 ms 31688 KB Output is correct
21 Correct 8 ms 31568 KB Output is correct
22 Correct 3 ms 2896 KB Output is correct
23 Correct 11 ms 31824 KB Output is correct
24 Correct 3 ms 2896 KB Output is correct
25 Correct 11 ms 31824 KB Output is correct
26 Correct 10 ms 32000 KB Output is correct
27 Correct 10 ms 31760 KB Output is correct
28 Correct 11 ms 31824 KB Output is correct
29 Correct 10 ms 31824 KB Output is correct
30 Correct 14 ms 31992 KB Output is correct
31 Correct 11 ms 31824 KB Output is correct
32 Correct 15 ms 31824 KB Output is correct
33 Correct 12 ms 31824 KB Output is correct
34 Correct 11 ms 31824 KB Output is correct
35 Correct 6 ms 17232 KB Output is correct
36 Correct 6 ms 17104 KB Output is correct
37 Correct 6 ms 17232 KB Output is correct
38 Correct 4 ms 8784 KB Output is correct
39 Correct 4 ms 9032 KB Output is correct
40 Correct 16 ms 32140 KB Output is correct
41 Correct 4 ms 8784 KB Output is correct
42 Correct 15 ms 32216 KB Output is correct
43 Correct 14 ms 32140 KB Output is correct
44 Correct 340 ms 48072 KB Output is correct
45 Correct 1 ms 336 KB Output is correct
46 Correct 17 ms 32140 KB Output is correct
47 Correct 31 ms 32908 KB Output is correct
48 Correct 15 ms 32140 KB Output is correct
49 Correct 25 ms 32908 KB Output is correct
50 Correct 23 ms 32908 KB Output is correct
51 Correct 44 ms 34056 KB Output is correct
52 Correct 7 ms 3152 KB Output is correct
53 Correct 42 ms 34068 KB Output is correct
54 Correct 50 ms 34300 KB Output is correct
55 Correct 11 ms 31824 KB Output is correct
56 Correct 6 ms 3152 KB Output is correct
57 Correct 3 ms 848 KB Output is correct
58 Correct 39 ms 29960 KB Output is correct
59 Correct 31 ms 32908 KB Output is correct
60 Correct 11 ms 31824 KB Output is correct
61 Correct 36 ms 32868 KB Output is correct
62 Correct 33 ms 32920 KB Output is correct
63 Correct 350 ms 48132 KB Output is correct
64 Correct 192 ms 40188 KB Output is correct
65 Correct 15 ms 32140 KB Output is correct
66 Correct 32 ms 32924 KB Output is correct
67 Correct 105 ms 36608 KB Output is correct
68 Correct 195 ms 40476 KB Output is correct
69 Correct 18 ms 32140 KB Output is correct
70 Correct 34 ms 33032 KB Output is correct
71 Correct 105 ms 36620 KB Output is correct
72 Correct 65 ms 34856 KB Output is correct
73 Correct 12 ms 31824 KB Output is correct
74 Correct 31 ms 33112 KB Output is correct
75 Correct 66 ms 34680 KB Output is correct
76 Correct 18 ms 32304 KB Output is correct
77 Correct 29 ms 33032 KB Output is correct
78 Correct 11 ms 31824 KB Output is correct
79 Correct 13 ms 17804 KB Output is correct
80 Correct 17 ms 32140 KB Output is correct
81 Correct 27 ms 33032 KB Output is correct
82 Correct 4 ms 8796 KB Output is correct
83 Correct 12 ms 17804 KB Output is correct
84 Correct 23 ms 32888 KB Output is correct
85 Correct 4 ms 8784 KB Output is correct
86 Correct 25 ms 32908 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 10 ms 31824 KB Output is correct
4 Correct 7 ms 11512 KB Output is correct
5 Correct 7 ms 13392 KB Output is correct
6 Correct 9 ms 31824 KB Output is correct
7 Correct 10 ms 31984 KB Output is correct
8 Correct 3 ms 848 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 3 ms 2896 KB Output is correct
11 Correct 9 ms 9296 KB Output is correct
12 Correct 7 ms 11508 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 7 ms 19536 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 10 ms 31824 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 10 ms 31768 KB Output is correct
19 Correct 3 ms 848 KB Output is correct
20 Correct 8 ms 31688 KB Output is correct
21 Correct 8 ms 31568 KB Output is correct
22 Correct 3 ms 2896 KB Output is correct
23 Correct 11 ms 31824 KB Output is correct
24 Correct 3 ms 2896 KB Output is correct
25 Correct 11 ms 31824 KB Output is correct
26 Correct 10 ms 32000 KB Output is correct
27 Correct 10 ms 31760 KB Output is correct
28 Correct 11 ms 31824 KB Output is correct
29 Correct 10 ms 31824 KB Output is correct
30 Correct 14 ms 31992 KB Output is correct
31 Correct 11 ms 31824 KB Output is correct
32 Correct 15 ms 31824 KB Output is correct
33 Correct 12 ms 31824 KB Output is correct
34 Correct 11 ms 31824 KB Output is correct
35 Correct 6 ms 17232 KB Output is correct
36 Correct 6 ms 17104 KB Output is correct
37 Correct 6 ms 17232 KB Output is correct
38 Correct 4 ms 8784 KB Output is correct
39 Correct 4 ms 9032 KB Output is correct
40 Correct 16 ms 32140 KB Output is correct
41 Correct 4 ms 8784 KB Output is correct
42 Correct 15 ms 32216 KB Output is correct
43 Correct 14 ms 32140 KB Output is correct
44 Correct 1 ms 336 KB Output is correct
45 Correct 209 ms 289572 KB Output is correct
46 Correct 148 ms 298236 KB Output is correct
47 Correct 206 ms 320184 KB Output is correct
48 Correct 207 ms 320368 KB Output is correct
49 Correct 80 ms 199160 KB Output is correct
50 Correct 204 ms 305140 KB Output is correct
51 Correct 207 ms 320172 KB Output is correct
52 Correct 105 ms 311908 KB Output is correct
53 Correct 82 ms 215756 KB Output is correct
54 Correct 24 ms 3588 KB Output is correct
55 Correct 224 ms 318460 KB Output is correct
56 Correct 89 ms 310324 KB Output is correct
57 Correct 113 ms 307708 KB Output is correct
58 Correct 230 ms 316936 KB Output is correct
59 Correct 92 ms 308476 KB Output is correct
60 Correct 91 ms 308236 KB Output is correct
61 Correct 226 ms 312568 KB Output is correct
62 Correct 148 ms 304892 KB Output is correct
63 Correct 171 ms 314668 KB Output is correct
64 Correct 89 ms 310532 KB Output is correct
65 Correct 212 ms 316152 KB Output is correct
66 Correct 143 ms 312916 KB Output is correct
67 Correct 176 ms 314620 KB Output is correct
68 Correct 178 ms 315128 KB Output is correct
69 Correct 205 ms 316148 KB Output is correct
70 Correct 117 ms 312072 KB Output is correct
71 Correct 184 ms 315124 KB Output is correct
72 Correct 152 ms 314620 KB Output is correct
73 Correct 207 ms 316020 KB Output is correct
74 Correct 121 ms 309840 KB Output is correct
75 Correct 82 ms 158472 KB Output is correct
76 Correct 144 ms 314624 KB Output is correct
77 Correct 202 ms 315948 KB Output is correct
78 Correct 90 ms 159228 KB Output is correct
79 Correct 76 ms 156412 KB Output is correct
80 Correct 36 ms 78476 KB Output is correct
81 Correct 89 ms 159292 KB Output is correct
82 Correct 156 ms 314652 KB Output is correct
83 Correct 36 ms 80524 KB Output is correct
84 Correct 153 ms 314620 KB Output is correct