# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
775790 |
2023-07-07T01:26:36 Z |
horiiseun |
Paths (BOI18_paths) |
C++17 |
|
58 ms |
26316 KB |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, m, k, colours[300005], dp[300005][35], ans;
vector<int> adj[300005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) {
cin >> colours[i];
colours[i]--;
dp[i][1 << colours[i]] = 1;
}
for (int i = 0, a, b; i < m; i++) {
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
for (int i = 2; i <= 5; i++) {
vector<int> nxt;
for (int j = 1; j < 32; j++) {
if (__builtin_popcount(j) == i) {
nxt.push_back(j);
}
}
for (int j = 1; i <= n; j++) {
for (int k : adj[j]) {
for (int m : nxt) {
if (m >> colours[j] & 1) {
dp[j][m] += dp[k][m ^ (1 << colours[j])];
}
}
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j < 32; j++) {
ans += dp[i][j];
}
}
cout << ans - n << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
14676 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
58 ms |
26316 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
14676 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
10 ms |
14676 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |