# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
522509 | Leonardo_Paes | Paths (BOI18_paths) | C++17 | 83 ms | 15348 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10, maxl = 1<<5 - 1;
int c[maxn];
vector<int> grafo[maxn];
int dp[maxn][maxl];
int solve(int u, int mask){
if(dp[u][mask] != -1) return dp[u][mask];
int tot = 1;
for(int v : grafo[u]) if(!(mask&c[v])) tot += solve(v, mask^c[v]);
return dp[u][mask] = tot;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int n, m, k;
cin >> n >> m >> k;
for(int i=1; i<=n; i++){
cin >> c[i];
c[i] = (1<<(c[i]-1));
}
for(int i=1; i<=m; i++){
int u, v;
cin >> u >> v;
grafo[u].push_back(v);
grafo[v].push_back(u);
}
long long ans = 0;
memset(dp, -1, sizeof dp);
for(int i=1; i<=n; i++) ans += solve(i, c[i]);
cout << ans - n << "\n";
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... |