# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
236944 | PeppaPig | Paths (BOI18_paths) | C++14 | 435 ms | 97248 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define long long long
using namespace std;
const int N = 3e5 + 5;
int n, m, k, col[N];
long dp[N][1 << 5], ans;
vector<int> g[N], bit[10];
int main() {
scanf("%d %d %d", &n, &m, &k);
for(int i = 1; i <= n; i++) {
scanf("%d", col + i);
--col[i];
dp[i][1 << col[i]] = 1;
}
for(int i = 1, a, b; i <= m; i++) {
scanf("%d %d", &a, &b);
g[a].emplace_back(b), g[b].emplace_back(a);
}
for(int i = 1; i < (1 << k); i++)
bit[__builtin_popcount(i)].emplace_back(i);
for(int i = 2; i <= k; i++) for(int b : bit[i]) for(int u = 1; u <= n; u++) {
if(b >> col[u] & 1) for(int v : g[u])
dp[u][b] += dp[v][b ^ (1 << col[u])];
ans += dp[u][b];
}
printf("%lld\n", ans);
return 0;
}
컴파일 시 표준 에러 (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... |