#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("VNOICUP.INP");
ofstream fout("VNOICUP.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
const ll mod = 1000001;
const int mxn = 3e5 + 1, mxq = 2e5 + 5, sq = 400, mxv = 2e7 + 5, p = 31;
//const int base = (1 << 18);
const ll inf = 1e9 + 5, neg = -69420;
ll dp[mxn + 1][(1 << 5)], c[mxn + 1];
int n, m, k;
vt<int>adj[mxn + 1];
void input(){
cin >> n >> m >> k;
for(int i = 1; i <= n; i++){
cin >> c[i]; c[i]--;
dp[i][(1 << c[i])] = 1;
}
forr(i, 0, m){
int u, v; cin >> u >> v;
adj[u].pb(v); adj[v].pb(u);
}
}
void process(){
ll ans = 0;
for(int i = 1; i < (1 << k); i++){
for(int j = 1; j <= n; j++){
if((i >> c[j]) & 1){
for(auto l: adj[j]){
dp[j][i] += dp[l][i ^ (1 << c[j])];
}
}
ans += dp[j][i];
}
}
cout << ans - n;
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
input();
process();
return(0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7380 KB |
Output is correct |
2 |
Correct |
4 ms |
7380 KB |
Output is correct |
3 |
Correct |
3 ms |
7380 KB |
Output is correct |
4 |
Correct |
3 ms |
7380 KB |
Output is correct |
5 |
Correct |
3 ms |
7380 KB |
Output is correct |
6 |
Correct |
3 ms |
7380 KB |
Output is correct |
7 |
Correct |
3 ms |
7380 KB |
Output is correct |
8 |
Correct |
4 ms |
7380 KB |
Output is correct |
9 |
Correct |
3 ms |
7356 KB |
Output is correct |
10 |
Correct |
3 ms |
7356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
50 ms |
12208 KB |
Output is correct |
2 |
Correct |
36 ms |
11072 KB |
Output is correct |
3 |
Correct |
201 ms |
97588 KB |
Output is correct |
4 |
Correct |
77 ms |
22900 KB |
Output is correct |
5 |
Correct |
68 ms |
22860 KB |
Output is correct |
6 |
Correct |
187 ms |
70220 KB |
Output is correct |
7 |
Correct |
205 ms |
97704 KB |
Output is correct |
8 |
Correct |
233 ms |
98496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7380 KB |
Output is correct |
2 |
Correct |
4 ms |
7380 KB |
Output is correct |
3 |
Correct |
3 ms |
7380 KB |
Output is correct |
4 |
Correct |
3 ms |
7380 KB |
Output is correct |
5 |
Correct |
3 ms |
7380 KB |
Output is correct |
6 |
Correct |
3 ms |
7380 KB |
Output is correct |
7 |
Correct |
3 ms |
7380 KB |
Output is correct |
8 |
Correct |
4 ms |
7380 KB |
Output is correct |
9 |
Correct |
3 ms |
7356 KB |
Output is correct |
10 |
Correct |
3 ms |
7356 KB |
Output is correct |
11 |
Correct |
50 ms |
12208 KB |
Output is correct |
12 |
Correct |
36 ms |
11072 KB |
Output is correct |
13 |
Correct |
201 ms |
97588 KB |
Output is correct |
14 |
Correct |
77 ms |
22900 KB |
Output is correct |
15 |
Correct |
68 ms |
22860 KB |
Output is correct |
16 |
Correct |
187 ms |
70220 KB |
Output is correct |
17 |
Correct |
205 ms |
97704 KB |
Output is correct |
18 |
Correct |
233 ms |
98496 KB |
Output is correct |
19 |
Correct |
46 ms |
15016 KB |
Output is correct |
20 |
Correct |
37 ms |
13356 KB |
Output is correct |
21 |
Correct |
203 ms |
97712 KB |
Output is correct |
22 |
Correct |
68 ms |
22840 KB |
Output is correct |
23 |
Correct |
73 ms |
22820 KB |
Output is correct |
24 |
Correct |
155 ms |
70132 KB |
Output is correct |
25 |
Correct |
201 ms |
97668 KB |
Output is correct |
26 |
Correct |
223 ms |
98356 KB |
Output is correct |
27 |
Correct |
40 ms |
13384 KB |
Output is correct |
28 |
Correct |
54 ms |
16696 KB |
Output is correct |
29 |
Correct |
302 ms |
97700 KB |
Output is correct |
30 |
Correct |
177 ms |
55896 KB |
Output is correct |
31 |
Correct |
220 ms |
55940 KB |
Output is correct |
32 |
Correct |
297 ms |
97704 KB |
Output is correct |
33 |
Correct |
4 ms |
7380 KB |
Output is correct |
34 |
Correct |
3 ms |
7380 KB |
Output is correct |
35 |
Correct |
3 ms |
7380 KB |
Output is correct |
36 |
Correct |
3 ms |
7384 KB |
Output is correct |
37 |
Correct |
3 ms |
7380 KB |
Output is correct |
38 |
Correct |
3 ms |
7380 KB |
Output is correct |
39 |
Correct |
5 ms |
7380 KB |
Output is correct |
40 |
Correct |
3 ms |
7380 KB |
Output is correct |
41 |
Correct |
3 ms |
7380 KB |
Output is correct |
42 |
Correct |
3 ms |
7384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
7380 KB |
Output is correct |
2 |
Correct |
16 ms |
8516 KB |
Output is correct |
3 |
Correct |
17 ms |
8532 KB |
Output is correct |
4 |
Correct |
57 ms |
37204 KB |
Output is correct |
5 |
Correct |
50 ms |
38088 KB |
Output is correct |
6 |
Correct |
126 ms |
37336 KB |
Output is correct |
7 |
Correct |
15 ms |
9300 KB |
Output is correct |
8 |
Correct |
81 ms |
37336 KB |
Output is correct |
9 |
Correct |
62 ms |
38048 KB |
Output is correct |
10 |
Correct |
74 ms |
38140 KB |
Output is correct |
11 |
Correct |
63 ms |
23240 KB |
Output is correct |
12 |
Correct |
75 ms |
30812 KB |
Output is correct |
13 |
Correct |
59 ms |
23428 KB |
Output is correct |
14 |
Correct |
136 ms |
37252 KB |
Output is correct |
15 |
Correct |
113 ms |
37440 KB |
Output is correct |
16 |
Correct |
3 ms |
7380 KB |
Output is correct |
17 |
Correct |
3 ms |
7380 KB |
Output is correct |
18 |
Correct |
3 ms |
7380 KB |
Output is correct |
19 |
Correct |
4 ms |
7388 KB |
Output is correct |
20 |
Correct |
4 ms |
7380 KB |
Output is correct |
21 |
Correct |
4 ms |
7380 KB |
Output is correct |
22 |
Correct |
3 ms |
7380 KB |
Output is correct |
23 |
Correct |
3 ms |
7380 KB |
Output is correct |
24 |
Correct |
3 ms |
7384 KB |
Output is correct |
25 |
Correct |
4 ms |
7380 KB |
Output is correct |