#include<iostream>
#include<vector>
using namespace std;
long long Dp[35][300005];
int Col[300005];
vector<int> A[300005];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,m,k;
cin>>n>>m>>k;
for(int i=1; i<=n; i++)
{
cin>>Col[i];
Col[i]--;
Dp[1<<Col[i]][i]=1;
}
for(int i=1; i<=m; i++)
{
int x,y;
cin>>x>>y;
A[x].push_back(y);
A[y].push_back(x);
}
long long rez=0;
for(int conf=1; conf<(1<<k); conf++) //tot timpul o sa parcurg config din care se poate obtine conf inainte de conf
{
for(int i=1; i<=n; i++)
{
if(Dp[conf][i]==0)
continue;
rez+=Dp[conf][i];
for(auto other:A[i])
{
if(conf&(1<<Col[other]))
continue;
Dp[conf^(1<<Col[other])][other]+=Dp[conf][i];
}
}
}
cout<<rez-n<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
7544 KB |
Output is correct |
2 |
Correct |
9 ms |
7544 KB |
Output is correct |
3 |
Correct |
11 ms |
7436 KB |
Output is correct |
4 |
Correct |
10 ms |
7400 KB |
Output is correct |
5 |
Correct |
9 ms |
7416 KB |
Output is correct |
6 |
Correct |
15 ms |
7416 KB |
Output is correct |
7 |
Correct |
10 ms |
7544 KB |
Output is correct |
8 |
Correct |
11 ms |
7544 KB |
Output is correct |
9 |
Correct |
11 ms |
7416 KB |
Output is correct |
10 |
Correct |
12 ms |
7516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
116 ms |
14144 KB |
Output is correct |
2 |
Correct |
88 ms |
13256 KB |
Output is correct |
3 |
Correct |
352 ms |
37944 KB |
Output is correct |
4 |
Correct |
158 ms |
16120 KB |
Output is correct |
5 |
Correct |
151 ms |
15608 KB |
Output is correct |
6 |
Correct |
276 ms |
30440 KB |
Output is correct |
7 |
Correct |
469 ms |
38068 KB |
Output is correct |
8 |
Correct |
381 ms |
38664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
7544 KB |
Output is correct |
2 |
Correct |
9 ms |
7544 KB |
Output is correct |
3 |
Correct |
11 ms |
7436 KB |
Output is correct |
4 |
Correct |
10 ms |
7400 KB |
Output is correct |
5 |
Correct |
9 ms |
7416 KB |
Output is correct |
6 |
Correct |
15 ms |
7416 KB |
Output is correct |
7 |
Correct |
10 ms |
7544 KB |
Output is correct |
8 |
Correct |
11 ms |
7544 KB |
Output is correct |
9 |
Correct |
11 ms |
7416 KB |
Output is correct |
10 |
Correct |
12 ms |
7516 KB |
Output is correct |
11 |
Correct |
116 ms |
14144 KB |
Output is correct |
12 |
Correct |
88 ms |
13256 KB |
Output is correct |
13 |
Correct |
352 ms |
37944 KB |
Output is correct |
14 |
Correct |
158 ms |
16120 KB |
Output is correct |
15 |
Correct |
151 ms |
15608 KB |
Output is correct |
16 |
Correct |
276 ms |
30440 KB |
Output is correct |
17 |
Correct |
469 ms |
38068 KB |
Output is correct |
18 |
Correct |
381 ms |
38664 KB |
Output is correct |
19 |
Correct |
113 ms |
14328 KB |
Output is correct |
20 |
Correct |
91 ms |
13188 KB |
Output is correct |
21 |
Correct |
368 ms |
38040 KB |
Output is correct |
22 |
Correct |
215 ms |
16120 KB |
Output is correct |
23 |
Correct |
154 ms |
15608 KB |
Output is correct |
24 |
Correct |
274 ms |
30404 KB |
Output is correct |
25 |
Correct |
392 ms |
38008 KB |
Output is correct |
26 |
Correct |
386 ms |
38512 KB |
Output is correct |
27 |
Correct |
107 ms |
13432 KB |
Output is correct |
28 |
Correct |
139 ms |
15736 KB |
Output is correct |
29 |
Correct |
465 ms |
56704 KB |
Output is correct |
30 |
Correct |
334 ms |
35568 KB |
Output is correct |
31 |
Correct |
348 ms |
33400 KB |
Output is correct |
32 |
Correct |
471 ms |
56824 KB |
Output is correct |
33 |
Correct |
9 ms |
7544 KB |
Output is correct |
34 |
Correct |
8 ms |
7544 KB |
Output is correct |
35 |
Correct |
9 ms |
7416 KB |
Output is correct |
36 |
Correct |
9 ms |
7416 KB |
Output is correct |
37 |
Correct |
9 ms |
7416 KB |
Output is correct |
38 |
Correct |
7 ms |
7544 KB |
Output is correct |
39 |
Correct |
9 ms |
7588 KB |
Output is correct |
40 |
Correct |
7 ms |
7544 KB |
Output is correct |
41 |
Correct |
9 ms |
7544 KB |
Output is correct |
42 |
Correct |
9 ms |
7416 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
7576 KB |
Output is correct |
2 |
Correct |
52 ms |
9600 KB |
Output is correct |
3 |
Correct |
35 ms |
9340 KB |
Output is correct |
4 |
Correct |
103 ms |
17432 KB |
Output is correct |
5 |
Correct |
79 ms |
17384 KB |
Output is correct |
6 |
Correct |
146 ms |
36320 KB |
Output is correct |
7 |
Correct |
42 ms |
9208 KB |
Output is correct |
8 |
Correct |
129 ms |
23688 KB |
Output is correct |
9 |
Correct |
92 ms |
20592 KB |
Output is correct |
10 |
Correct |
118 ms |
19748 KB |
Output is correct |
11 |
Correct |
120 ms |
22876 KB |
Output is correct |
12 |
Correct |
132 ms |
18932 KB |
Output is correct |
13 |
Correct |
104 ms |
19572 KB |
Output is correct |
14 |
Correct |
171 ms |
36484 KB |
Output is correct |
15 |
Correct |
150 ms |
36600 KB |
Output is correct |
16 |
Correct |
9 ms |
7544 KB |
Output is correct |
17 |
Correct |
9 ms |
7544 KB |
Output is correct |
18 |
Correct |
8 ms |
7492 KB |
Output is correct |
19 |
Correct |
9 ms |
7416 KB |
Output is correct |
20 |
Correct |
9 ms |
7416 KB |
Output is correct |
21 |
Correct |
9 ms |
7544 KB |
Output is correct |
22 |
Correct |
9 ms |
7672 KB |
Output is correct |
23 |
Correct |
9 ms |
7416 KB |
Output is correct |
24 |
Correct |
9 ms |
7544 KB |
Output is correct |
25 |
Correct |
9 ms |
7388 KB |
Output is correct |