Submission #63070

# Submission time Handle Problem Language Result Execution time Memory
63070 2018-07-31T15:52:11 Z zetapi Paths (BOI18_paths) C++14
100 / 100
752 ms 113824 KB
#include <bits/stdc++.h>
using namespace std;

#define pb  push_back
#define mp  make_pair
#define int long long
#define itr ::iterator 

typedef pair<int,int>  pii;

const int MAX=1e6;

pii edge[MAX];

int N,M,K,res,arr[MAX],dp[MAX][40];

signed main()
{
	ios_base::sync_with_stdio(false);
	
	cin>>N>>M>>K;
	for(int A=0;A<N;A++)
	{
		cin>>arr[A];
		arr[A]--;
	}
	for(int A=0;A<M;A++)
	{
		cin>>edge[A].first>>edge[A].second;
		edge[A].first--;
		edge[A].second--;
	}
	for(int A=0;A<N;A++)
		dp[A][(1<<arr[A])]=1;
	for(int A=2;A<=K;A++)
	{
		int u,v;
		for(int B=0;B<M;B++)
		{
			u=edge[B].first;
			v=edge[B].second;
			for(int C=0;C<(1<<K);C++)
			{
				if(((C&(1<<arr[v]))!=0) or __builtin_popcount(C)!=A-1)
					continue;
				dp[v][C|(1<<arr[v])]+=dp[u][C];
			}
			for(int C=0;C<(1<<K);C++)
			{
				if(((C&(1<<arr[u]))!=0) or __builtin_popcount(C)!=A-1)
					continue;
				dp[u][C|(1<<arr[u])]+=dp[v][C];
			}
		}

	}
	for(int A=0;A<N;A++)
		for(int B=0;B<(1<<K);B++)
			res+=dp[A][B];
	cout<<res-N;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 412 KB Output is correct
4 Correct 3 ms 412 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
7 Correct 2 ms 536 KB Output is correct
8 Correct 3 ms 536 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 3 ms 592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 132 ms 6864 KB Output is correct
2 Correct 129 ms 7912 KB Output is correct
3 Correct 405 ms 107984 KB Output is correct
4 Correct 120 ms 107984 KB Output is correct
5 Correct 95 ms 107984 KB Output is correct
6 Correct 321 ms 107984 KB Output is correct
7 Correct 473 ms 108016 KB Output is correct
8 Correct 477 ms 108052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 412 KB Output is correct
4 Correct 3 ms 412 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 2 ms 536 KB Output is correct
7 Correct 2 ms 536 KB Output is correct
8 Correct 3 ms 536 KB Output is correct
9 Correct 2 ms 592 KB Output is correct
10 Correct 3 ms 592 KB Output is correct
11 Correct 132 ms 6864 KB Output is correct
12 Correct 129 ms 7912 KB Output is correct
13 Correct 405 ms 107984 KB Output is correct
14 Correct 120 ms 107984 KB Output is correct
15 Correct 95 ms 107984 KB Output is correct
16 Correct 321 ms 107984 KB Output is correct
17 Correct 473 ms 108016 KB Output is correct
18 Correct 477 ms 108052 KB Output is correct
19 Correct 119 ms 108052 KB Output is correct
20 Correct 114 ms 108052 KB Output is correct
21 Correct 477 ms 108124 KB Output is correct
22 Correct 159 ms 108124 KB Output is correct
23 Correct 86 ms 108124 KB Output is correct
24 Correct 343 ms 108124 KB Output is correct
25 Correct 515 ms 113800 KB Output is correct
26 Correct 490 ms 113800 KB Output is correct
27 Correct 171 ms 113800 KB Output is correct
28 Correct 196 ms 113800 KB Output is correct
29 Correct 748 ms 113824 KB Output is correct
30 Correct 731 ms 113824 KB Output is correct
31 Correct 526 ms 113824 KB Output is correct
32 Correct 752 ms 113824 KB Output is correct
33 Correct 2 ms 113824 KB Output is correct
34 Correct 2 ms 113824 KB Output is correct
35 Correct 2 ms 113824 KB Output is correct
36 Correct 3 ms 113824 KB Output is correct
37 Correct 3 ms 113824 KB Output is correct
38 Correct 2 ms 113824 KB Output is correct
39 Correct 3 ms 113824 KB Output is correct
40 Correct 3 ms 113824 KB Output is correct
41 Correct 3 ms 113824 KB Output is correct
42 Correct 2 ms 113824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 113824 KB Output is correct
2 Correct 119 ms 113824 KB Output is correct
3 Correct 36 ms 113824 KB Output is correct
4 Correct 149 ms 113824 KB Output is correct
5 Correct 148 ms 113824 KB Output is correct
6 Correct 392 ms 113824 KB Output is correct
7 Correct 62 ms 113824 KB Output is correct
8 Correct 229 ms 113824 KB Output is correct
9 Correct 163 ms 113824 KB Output is correct
10 Correct 171 ms 113824 KB Output is correct
11 Correct 260 ms 113824 KB Output is correct
12 Correct 313 ms 113824 KB Output is correct
13 Correct 332 ms 113824 KB Output is correct
14 Correct 465 ms 113824 KB Output is correct
15 Correct 381 ms 113824 KB Output is correct
16 Correct 2 ms 113824 KB Output is correct
17 Correct 2 ms 113824 KB Output is correct
18 Correct 2 ms 113824 KB Output is correct
19 Correct 3 ms 113824 KB Output is correct
20 Correct 3 ms 113824 KB Output is correct
21 Correct 2 ms 113824 KB Output is correct
22 Correct 3 ms 113824 KB Output is correct
23 Correct 3 ms 113824 KB Output is correct
24 Correct 3 ms 113824 KB Output is correct
25 Correct 2 ms 113824 KB Output is correct