Submission #566227

# Submission time Handle Problem Language Result Execution time Memory
566227 2022-05-22T07:17:22 Z hollwo_pelw Paths (BOI18_paths) C++17
100 / 100
325 ms 52504 KB
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/trie_policy.hpp>
// #include <ext/rope>

using namespace std;
// using namespace __gnu_cxx;
// using namespace __gnu_pbds;

void Hollwo_Pelw();

signed main(){
#ifndef hollwo_pelw_local
	if (fopen(".inp", "r"))
		assert(freopen(".inp", "r", stdin)), assert(freopen(".out", "w", stdout));
#else
	using namespace chrono;
	auto start = steady_clock::now();
#endif
	cin.tie(0), cout.tie(0) -> sync_with_stdio(0);
	int testcases = 1;
	// cin >> testcases;
	for (int test = 1; test <= testcases; test++){
		// cout << "Case #" << test << ": ";
		Hollwo_Pelw();
	}
#ifdef hollwo_pelw_local
	auto end = steady_clock::now();
	cout << "\nExecution time : " << duration_cast<milliseconds> (end - start).count() << "[ms]" << endl;
#endif
}

const int N = 3e5 + 5;

long long dp[1 << 5][N], res;
int n, m, k, c[N];
vector<int> adj[N];

void Hollwo_Pelw(){
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++)
		cin >> c[i], c[i] --;
	for (int u, v; m --; ) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++)
		dp[1 << c[i]][i] = 1;
	
	for (int mask = 1; mask < 1 << k; mask++) {
		for (int u = 1; u <= n; u++) if (dp[mask][u]) {
			res += dp[mask][u];
			for (int v : adj[u])
				if ((mask >> c[v] & 1) == 0)
					dp[mask ^ 1 << c[v]][v] += dp[mask][u];
		}
	}
	cout << res - n << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 6 ms 7508 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 5 ms 7380 KB Output is correct
5 Correct 4 ms 7372 KB Output is correct
6 Correct 4 ms 7432 KB Output is correct
7 Correct 5 ms 7508 KB Output is correct
8 Correct 4 ms 7500 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 11604 KB Output is correct
2 Correct 64 ms 11220 KB Output is correct
3 Correct 273 ms 33696 KB Output is correct
4 Correct 95 ms 12832 KB Output is correct
5 Correct 81 ms 12400 KB Output is correct
6 Correct 207 ms 26424 KB Output is correct
7 Correct 280 ms 33580 KB Output is correct
8 Correct 266 ms 34160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 7380 KB Output is correct
2 Correct 6 ms 7508 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 5 ms 7380 KB Output is correct
5 Correct 4 ms 7372 KB Output is correct
6 Correct 4 ms 7432 KB Output is correct
7 Correct 5 ms 7508 KB Output is correct
8 Correct 4 ms 7500 KB Output is correct
9 Correct 4 ms 7380 KB Output is correct
10 Correct 4 ms 7380 KB Output is correct
11 Correct 73 ms 11604 KB Output is correct
12 Correct 64 ms 11220 KB Output is correct
13 Correct 273 ms 33696 KB Output is correct
14 Correct 95 ms 12832 KB Output is correct
15 Correct 81 ms 12400 KB Output is correct
16 Correct 207 ms 26424 KB Output is correct
17 Correct 280 ms 33580 KB Output is correct
18 Correct 266 ms 34160 KB Output is correct
19 Correct 74 ms 11540 KB Output is correct
20 Correct 64 ms 11232 KB Output is correct
21 Correct 254 ms 33524 KB Output is correct
22 Correct 100 ms 12864 KB Output is correct
23 Correct 100 ms 12404 KB Output is correct
24 Correct 187 ms 26572 KB Output is correct
25 Correct 284 ms 33628 KB Output is correct
26 Correct 283 ms 34408 KB Output is correct
27 Correct 75 ms 11340 KB Output is correct
28 Correct 90 ms 13044 KB Output is correct
29 Correct 325 ms 52380 KB Output is correct
30 Correct 223 ms 31600 KB Output is correct
31 Correct 261 ms 29464 KB Output is correct
32 Correct 306 ms 52504 KB Output is correct
33 Correct 5 ms 7380 KB Output is correct
34 Correct 5 ms 7504 KB Output is correct
35 Correct 6 ms 7380 KB Output is correct
36 Correct 5 ms 7380 KB Output is correct
37 Correct 5 ms 7368 KB Output is correct
38 Correct 5 ms 7380 KB Output is correct
39 Correct 4 ms 7380 KB Output is correct
40 Correct 4 ms 7508 KB Output is correct
41 Correct 5 ms 7380 KB Output is correct
42 Correct 4 ms 7380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7504 KB Output is correct
2 Correct 41 ms 9044 KB Output is correct
3 Correct 25 ms 8700 KB Output is correct
4 Correct 83 ms 16312 KB Output is correct
5 Correct 46 ms 16200 KB Output is correct
6 Correct 90 ms 35196 KB Output is correct
7 Correct 27 ms 8844 KB Output is correct
8 Correct 82 ms 22644 KB Output is correct
9 Correct 59 ms 19448 KB Output is correct
10 Correct 75 ms 18500 KB Output is correct
11 Correct 64 ms 21940 KB Output is correct
12 Correct 53 ms 17896 KB Output is correct
13 Correct 66 ms 18528 KB Output is correct
14 Correct 106 ms 35384 KB Output is correct
15 Correct 97 ms 35364 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 5 ms 7504 KB Output is correct
18 Correct 4 ms 7380 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 5 ms 7380 KB Output is correct
21 Correct 4 ms 7372 KB Output is correct
22 Correct 4 ms 7496 KB Output is correct
23 Correct 4 ms 7508 KB Output is correct
24 Correct 4 ms 7380 KB Output is correct
25 Correct 4 ms 7360 KB Output is correct