# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
440949 | BeanZ | Paths (BOI18_paths) | C++14 | 323 ms | 62648 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// I_Love_LPL 11m
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 1e5 + 5;
long long mod = 998244353;
const int lim = 4e5 + 5;
const int lg = 22;
const int base = 311;
const long double eps = 1e-6;
ll dp[N][(2 << 5) + 5], c[N];
vector<ll> node[N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
if (fopen("tests.inp", "r")){
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
}
ll n, m, k;
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) cin >> c[i];
for (int i = 1; i <= m; i++){
ll u, v;
cin >> u >> v;
node[u].push_back(v);
node[v].push_back(u);
}
for (int i = 1; i <= n; i++){
dp[i][(1 << (c[i] - 1))] = 1;
}
ll ans = 0;
for (int i = 0; i < (1 << k); i++){
for (int g = 1; g <= n; g++){
if (i & (1 << (c[g] - 1))){
for (auto d : node[g]){
dp[g][i] += dp[d][i ^ (1 << (c[g] - 1))];
}
}
ans = ans + dp[g][i];
}
}
cout << ans - n;
}
/*
Ans:
Out:
*/
컴파일 시 표준 에러 (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... |