Submission #524641

# Submission time Handle Problem Language Result Execution time Memory
524641 2022-02-09T17:39:23 Z Yazan_Alattar Paths (BOI18_paths) C++14
100 / 100
953 ms 180512 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 2000007;
const ll inf = 1e18;
const ll mod = 998244353;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
 
vector <int> adj[M];
ll n, m, k, col[M], dp[M][50], ans;
 
int main()
{
	cin >> n >> m >> k;
	for(int i = 1; i <= n; ++i) cin >> col[i], --col[i];
	for(int i = 1; i <= m; ++i){
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	for(int i = 1; i <= n; ++i) dp[i][(1 << col[i])] = 1;
	for(int mask = 1; mask < (1 << k); ++mask){
		for(int i = 1; i <= n; ++i){
			for(auto j : adj[i]) if(((mask >> col[j]) & 1) == 0){
				dp[j][(mask | (1 << col[j]))] += dp[i][mask];
			}
			ans += dp[i][mask];
		}
	}
	cout << ans - n << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 22 ms 47180 KB Output is correct
2 Correct 23 ms 47308 KB Output is correct
3 Correct 22 ms 47264 KB Output is correct
4 Correct 23 ms 47296 KB Output is correct
5 Correct 24 ms 47180 KB Output is correct
6 Correct 25 ms 47264 KB Output is correct
7 Correct 23 ms 47208 KB Output is correct
8 Correct 22 ms 47308 KB Output is correct
9 Correct 23 ms 47208 KB Output is correct
10 Correct 22 ms 47180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 187 ms 55716 KB Output is correct
2 Correct 162 ms 53372 KB Output is correct
3 Correct 615 ms 179864 KB Output is correct
4 Correct 233 ms 67012 KB Output is correct
5 Correct 199 ms 66932 KB Output is correct
6 Correct 458 ms 138352 KB Output is correct
7 Correct 603 ms 180040 KB Output is correct
8 Correct 609 ms 180512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 47180 KB Output is correct
2 Correct 23 ms 47308 KB Output is correct
3 Correct 22 ms 47264 KB Output is correct
4 Correct 23 ms 47296 KB Output is correct
5 Correct 24 ms 47180 KB Output is correct
6 Correct 25 ms 47264 KB Output is correct
7 Correct 23 ms 47208 KB Output is correct
8 Correct 22 ms 47308 KB Output is correct
9 Correct 23 ms 47208 KB Output is correct
10 Correct 22 ms 47180 KB Output is correct
11 Correct 187 ms 55716 KB Output is correct
12 Correct 162 ms 53372 KB Output is correct
13 Correct 615 ms 179864 KB Output is correct
14 Correct 233 ms 67012 KB Output is correct
15 Correct 199 ms 66932 KB Output is correct
16 Correct 458 ms 138352 KB Output is correct
17 Correct 603 ms 180040 KB Output is correct
18 Correct 609 ms 180512 KB Output is correct
19 Correct 208 ms 55712 KB Output is correct
20 Correct 163 ms 53340 KB Output is correct
21 Correct 626 ms 179904 KB Output is correct
22 Correct 240 ms 67036 KB Output is correct
23 Correct 206 ms 66964 KB Output is correct
24 Correct 433 ms 138416 KB Output is correct
25 Correct 618 ms 179760 KB Output is correct
26 Correct 616 ms 180508 KB Output is correct
27 Correct 204 ms 53444 KB Output is correct
28 Correct 243 ms 57612 KB Output is correct
29 Correct 953 ms 179896 KB Output is correct
30 Correct 555 ms 117004 KB Output is correct
31 Correct 564 ms 116912 KB Output is correct
32 Correct 920 ms 179860 KB Output is correct
33 Correct 32 ms 47176 KB Output is correct
34 Correct 25 ms 47308 KB Output is correct
35 Correct 26 ms 47220 KB Output is correct
36 Correct 27 ms 47180 KB Output is correct
37 Correct 27 ms 47228 KB Output is correct
38 Correct 25 ms 47180 KB Output is correct
39 Correct 25 ms 47180 KB Output is correct
40 Correct 27 ms 47312 KB Output is correct
41 Correct 26 ms 47336 KB Output is correct
42 Correct 27 ms 47180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 47192 KB Output is correct
2 Correct 100 ms 49300 KB Output is correct
3 Correct 71 ms 49216 KB Output is correct
4 Correct 171 ms 91304 KB Output is correct
5 Correct 164 ms 91992 KB Output is correct
6 Correct 361 ms 91304 KB Output is correct
7 Correct 92 ms 49252 KB Output is correct
8 Correct 259 ms 91360 KB Output is correct
9 Correct 187 ms 91960 KB Output is correct
10 Correct 206 ms 91928 KB Output is correct
11 Correct 224 ms 70332 KB Output is correct
12 Correct 220 ms 81240 KB Output is correct
13 Correct 197 ms 70280 KB Output is correct
14 Correct 363 ms 91300 KB Output is correct
15 Correct 360 ms 91316 KB Output is correct
16 Correct 26 ms 47260 KB Output is correct
17 Correct 25 ms 47288 KB Output is correct
18 Correct 25 ms 47172 KB Output is correct
19 Correct 27 ms 47220 KB Output is correct
20 Correct 25 ms 47284 KB Output is correct
21 Correct 25 ms 47196 KB Output is correct
22 Correct 25 ms 47228 KB Output is correct
23 Correct 25 ms 47308 KB Output is correct
24 Correct 25 ms 47248 KB Output is correct
25 Correct 25 ms 47160 KB Output is correct