# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
426254 | lovrot | Paths (BOI18_paths) | C++11 | 73 ms | 11040 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define X first
#define Y second
#define ll long long
using namespace std;
const int N = 2010;
int n,a,b;
int c[N];
long long int out;
long long int memo[N][N];
vector<int> p[N];
long long int dfs(int x,int y){
if(memo[x][y] != 0)
return memo[x][y];
memo[x][y] = 1;
for(int i=0;i<p[x].size();i++){
if((1<<c[p[x][i]]) & y)
continue;
memo[x][y]+=dfs(p[x][i],y+(1<<c[p[x][i]]));
}
return memo[x][y];
}
int main(){
ios_base::sync_with_stdio(false);
int m,k;
cin >> n >> m >> k;
for(int i=0;i<n;i++)
cin >> c[i];
for(int i=0;i<m;i++){
cin >> a >> b;
a--;
b--;
p[a].push_back(b);
p[b].push_back(a);
}
for(int i=0;i<n;i++){
out+=dfs(i,0+(1<<c[i]));
}
cout<< out-n << "\n";
return 0;
}
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... |