| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1286637 | SmuggingSpun | Paths (BOI18_paths) | C++20 | 328 ms | 66332 KiB |
#include<bits/stdc++.h>
#define taskname "C"
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
int n, m, k;
cin >> n >> m >> k;
vector<vector<ll>>f(n + 1, vector<ll>(1 << k, 0LL));
vector<int>c(n + 1);
for(int i = 1; i <= n; i++){
cin >> c[i];
f[i][1 << --c[i]] = 1;
}
vector<vector<int>>g(n + 1);
for(int i = 0; i < m; i++){
int u, v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
for(int mask = 1; mask < (1 << k); mask++){
for(int u = 1; u <= n; u++){
for(int& v : g[u]){
if((mask >> c[v] & 1) == 0){
f[v][mask | (1 << c[v])] += f[u][mask];
}
}
}
}
ll ans = 0;
for(int i = 1; i <= n; i++){
ans += accumulate(f[i].begin(), f[i].end(), 0LL);
}
cout << ans - n;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
