Submission #881097

# Submission time Handle Problem Language Result Execution time Memory
881097 2023-11-30T14:49:46 Z OAleksa Paths (BOI18_paths) C++14
100 / 100
290 ms 100464 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
const int maxn = 3e5 + 69;
int n, m, k, a[maxn], dp[maxn][1 << 5];
vector<int> g[maxn];
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
   int tt = 1;
  	//cin >> tt;
   while (tt--) {
   	cin >> n >> m >> k;
   	for (int i = 1;i <= n;i++) {
   		cin >> a[i];
   		--a[i];
   		dp[i][1 << a[i]] = 1;
   	}
   	for (int i = 1;i <= m;i++) {
   		int a, b;
   		cin >> a >> b;
   		g[a].push_back(b);
   		g[b].push_back(a);
   	}
   	for (int mask = 1;mask < (1 << k);mask++) {
   		int x = __builtin_popcount(mask);
   		if (x == 1)
   			continue;
   		for (int i = 1;i <= n;i++) {
   			if (mask & (1 << a[i])) {
   				for (auto u : g[i]) {
   					dp[i][mask] += dp[u][mask ^ (1 << a[i])];
   				}
   			}
   		}
   	}
   	int ans = 0;
   	for (int i = 1;i <= n;i++) {
   		for (int j = 0;j < (1 << k);j++)
   			ans += dp[i][j];
   	}
   	ans -= n;
   	cout << ans;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10840 KB Output is correct
2 Correct 2 ms 10844 KB Output is correct
3 Correct 3 ms 10844 KB Output is correct
4 Correct 2 ms 10844 KB Output is correct
5 Correct 3 ms 10844 KB Output is correct
6 Correct 3 ms 10844 KB Output is correct
7 Correct 2 ms 10844 KB Output is correct
8 Correct 2 ms 10840 KB Output is correct
9 Correct 3 ms 10844 KB Output is correct
10 Correct 2 ms 10844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 18004 KB Output is correct
2 Correct 36 ms 17924 KB Output is correct
3 Correct 196 ms 95384 KB Output is correct
4 Correct 62 ms 29128 KB Output is correct
5 Correct 65 ms 29180 KB Output is correct
6 Correct 140 ms 70868 KB Output is correct
7 Correct 174 ms 99920 KB Output is correct
8 Correct 170 ms 100384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10840 KB Output is correct
2 Correct 2 ms 10844 KB Output is correct
3 Correct 3 ms 10844 KB Output is correct
4 Correct 2 ms 10844 KB Output is correct
5 Correct 3 ms 10844 KB Output is correct
6 Correct 3 ms 10844 KB Output is correct
7 Correct 2 ms 10844 KB Output is correct
8 Correct 2 ms 10840 KB Output is correct
9 Correct 3 ms 10844 KB Output is correct
10 Correct 2 ms 10844 KB Output is correct
11 Correct 44 ms 18004 KB Output is correct
12 Correct 36 ms 17924 KB Output is correct
13 Correct 196 ms 95384 KB Output is correct
14 Correct 62 ms 29128 KB Output is correct
15 Correct 65 ms 29180 KB Output is correct
16 Correct 140 ms 70868 KB Output is correct
17 Correct 174 ms 99920 KB Output is correct
18 Correct 170 ms 100384 KB Output is correct
19 Correct 47 ms 20720 KB Output is correct
20 Correct 36 ms 20204 KB Output is correct
21 Correct 238 ms 99924 KB Output is correct
22 Correct 62 ms 32664 KB Output is correct
23 Correct 61 ms 32412 KB Output is correct
24 Correct 132 ms 74940 KB Output is correct
25 Correct 188 ms 100180 KB Output is correct
26 Correct 168 ms 100464 KB Output is correct
27 Correct 38 ms 20048 KB Output is correct
28 Correct 54 ms 26256 KB Output is correct
29 Correct 253 ms 100020 KB Output is correct
30 Correct 182 ms 62416 KB Output is correct
31 Correct 186 ms 62580 KB Output is correct
32 Correct 290 ms 100248 KB Output is correct
33 Correct 2 ms 10844 KB Output is correct
34 Correct 3 ms 10896 KB Output is correct
35 Correct 2 ms 10844 KB Output is correct
36 Correct 2 ms 10844 KB Output is correct
37 Correct 3 ms 10844 KB Output is correct
38 Correct 2 ms 10844 KB Output is correct
39 Correct 2 ms 10844 KB Output is correct
40 Correct 2 ms 10844 KB Output is correct
41 Correct 2 ms 10844 KB Output is correct
42 Correct 2 ms 10908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 10844 KB Output is correct
2 Correct 16 ms 13088 KB Output is correct
3 Correct 17 ms 13660 KB Output is correct
4 Correct 46 ms 42216 KB Output is correct
5 Correct 36 ms 42700 KB Output is correct
6 Correct 108 ms 42400 KB Output is correct
7 Correct 14 ms 13660 KB Output is correct
8 Correct 68 ms 42424 KB Output is correct
9 Correct 51 ms 42704 KB Output is correct
10 Correct 59 ms 42952 KB Output is correct
11 Correct 60 ms 29132 KB Output is correct
12 Correct 64 ms 35648 KB Output is correct
13 Correct 51 ms 29260 KB Output is correct
14 Correct 112 ms 42324 KB Output is correct
15 Correct 107 ms 42508 KB Output is correct
16 Correct 2 ms 10844 KB Output is correct
17 Correct 2 ms 10844 KB Output is correct
18 Correct 2 ms 10844 KB Output is correct
19 Correct 2 ms 10844 KB Output is correct
20 Correct 2 ms 10904 KB Output is correct
21 Correct 2 ms 10840 KB Output is correct
22 Correct 3 ms 10844 KB Output is correct
23 Correct 2 ms 10840 KB Output is correct
24 Correct 3 ms 10844 KB Output is correct
25 Correct 2 ms 10844 KB Output is correct