# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
853144 |
2023-09-23T13:29:34 Z |
wakandaaa |
Paths (BOI18_paths) |
C++17 |
|
493 ms |
100528 KB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define file ""
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define getbit(x, i) (((x) >> (i)) & 1)
#define bit(x) (1LL << (x))
#define popcount __builtin_popcountll
mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r) {
return l + rd() % (r - l + 1);
}
const int N = 3e5 + 5;
const int mod = (int)1e9 + 7; // 998244353;
const int lg = 25; // lg + 1
const int oo = 1e9;
const long long ooo = 1e18;
template<class X, class Y> bool mini(X &a, Y b) {
return a > b ? (a = b, true) : false;
}
template<class X, class Y> bool maxi(X &a, Y b) {
return a < b ? (a = b, true) : false;
}
void add(int &a, int b) {
a += b;
if (a >= mod) a -= mod;
if (a < 0) a += mod;
}
int n, m, k;
vector<int> adj[N];
int a[N];
int f[N][1 << 5];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
// freopen(file".inp", "r", stdin);
// freopen(file".out", "w", stdout);
cin >> n >> m >> k;
for (int i = 0; i < n; ++i) {
cin >> a[i];
--a[i];
}
for (int i = 0; i < m; ++i) {
int u, v;
cin >> u >> v;
--u, --v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int i = 0; i < n; ++i) {
f[i][1 << a[i]] = 1;
}
for (int mask = 0; mask < bit(k); ++mask) {
for (int i = 0; i < k; ++i) if (getbit(mask, i)) {
for (int u = 0; u < n; ++u) {
for (int v : adj[u]) if (a[v] == i) {
f[v][mask] += f[u][mask ^ bit(i)];
}
}
}
}
int res = 0;
for (int i = 0; i < n; ++i) for (int mask = 0; mask < bit(k); ++mask) {
res += f[i][mask];
}
cout << res - n;
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 |
2 ms |
10840 KB |
Output is correct |
4 |
Correct |
2 ms |
10840 KB |
Output is correct |
5 |
Correct |
2 ms |
10844 KB |
Output is correct |
6 |
Correct |
2 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 |
2 ms |
10844 KB |
Output is correct |
10 |
Correct |
2 ms |
10844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
23176 KB |
Output is correct |
2 |
Correct |
64 ms |
22556 KB |
Output is correct |
3 |
Correct |
309 ms |
99980 KB |
Output is correct |
4 |
Correct |
81 ms |
30604 KB |
Output is correct |
5 |
Correct |
71 ms |
30800 KB |
Output is correct |
6 |
Correct |
196 ms |
75300 KB |
Output is correct |
7 |
Correct |
270 ms |
99828 KB |
Output is correct |
8 |
Correct |
296 ms |
100528 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 |
2 ms |
10840 KB |
Output is correct |
4 |
Correct |
2 ms |
10840 KB |
Output is correct |
5 |
Correct |
2 ms |
10844 KB |
Output is correct |
6 |
Correct |
2 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 |
2 ms |
10844 KB |
Output is correct |
10 |
Correct |
2 ms |
10844 KB |
Output is correct |
11 |
Correct |
76 ms |
23176 KB |
Output is correct |
12 |
Correct |
64 ms |
22556 KB |
Output is correct |
13 |
Correct |
309 ms |
99980 KB |
Output is correct |
14 |
Correct |
81 ms |
30604 KB |
Output is correct |
15 |
Correct |
71 ms |
30800 KB |
Output is correct |
16 |
Correct |
196 ms |
75300 KB |
Output is correct |
17 |
Correct |
270 ms |
99828 KB |
Output is correct |
18 |
Correct |
296 ms |
100528 KB |
Output is correct |
19 |
Correct |
77 ms |
22976 KB |
Output is correct |
20 |
Correct |
66 ms |
22540 KB |
Output is correct |
21 |
Correct |
282 ms |
99976 KB |
Output is correct |
22 |
Correct |
86 ms |
30800 KB |
Output is correct |
23 |
Correct |
79 ms |
31292 KB |
Output is correct |
24 |
Correct |
188 ms |
75204 KB |
Output is correct |
25 |
Correct |
312 ms |
99984 KB |
Output is correct |
26 |
Correct |
309 ms |
100372 KB |
Output is correct |
27 |
Correct |
93 ms |
22352 KB |
Output is correct |
28 |
Correct |
119 ms |
24620 KB |
Output is correct |
29 |
Correct |
486 ms |
99924 KB |
Output is correct |
30 |
Correct |
330 ms |
62664 KB |
Output is correct |
31 |
Correct |
347 ms |
62916 KB |
Output is correct |
32 |
Correct |
493 ms |
99992 KB |
Output is correct |
33 |
Correct |
2 ms |
10840 KB |
Output is correct |
34 |
Correct |
2 ms |
10844 KB |
Output is correct |
35 |
Correct |
2 ms |
10844 KB |
Output is correct |
36 |
Correct |
2 ms |
10844 KB |
Output is correct |
37 |
Correct |
2 ms |
10844 KB |
Output is correct |
38 |
Correct |
2 ms |
10844 KB |
Output is correct |
39 |
Correct |
2 ms |
10948 KB |
Output is correct |
40 |
Correct |
2 ms |
10844 KB |
Output is correct |
41 |
Correct |
2 ms |
10840 KB |
Output is correct |
42 |
Correct |
2 ms |
10844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
10844 KB |
Output is correct |
2 |
Correct |
55 ms |
13772 KB |
Output is correct |
3 |
Correct |
23 ms |
13916 KB |
Output is correct |
4 |
Correct |
73 ms |
42648 KB |
Output is correct |
5 |
Correct |
53 ms |
42956 KB |
Output is correct |
6 |
Correct |
229 ms |
42648 KB |
Output is correct |
7 |
Correct |
33 ms |
13912 KB |
Output is correct |
8 |
Correct |
129 ms |
42900 KB |
Output is correct |
9 |
Correct |
78 ms |
42952 KB |
Output is correct |
10 |
Correct |
100 ms |
42692 KB |
Output is correct |
11 |
Correct |
127 ms |
29108 KB |
Output is correct |
12 |
Correct |
123 ms |
36036 KB |
Output is correct |
13 |
Correct |
127 ms |
29368 KB |
Output is correct |
14 |
Correct |
218 ms |
42484 KB |
Output is correct |
15 |
Correct |
221 ms |
42588 KB |
Output is correct |
16 |
Correct |
2 ms |
10840 KB |
Output is correct |
17 |
Correct |
2 ms |
10952 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 |
10840 KB |
Output is correct |
21 |
Correct |
2 ms |
10844 KB |
Output is correct |
22 |
Correct |
2 ms |
10844 KB |
Output is correct |
23 |
Correct |
2 ms |
10944 KB |
Output is correct |
24 |
Correct |
2 ms |
10844 KB |
Output is correct |
25 |
Correct |
2 ms |
10844 KB |
Output is correct |