# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
941746 | dshfjka | Paths (BOI18_paths) | C++14 | 333 ms | 117648 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 LL long long
const LL N=3e5;
using namespace std;
LL n,m,k;
LL dp[N+5][35];
bool visited[N+5][35];
LL arr[N+5];
vector<LL>adj[N+5];
LL f(LL x, LL mask)
{
if(visited[x][mask])return dp[x][mask];
visited[x][mask]=1;
LL &dyn = dp[x][mask];
dyn=1;
for(LL a:adj[x])
{
if(mask&(1<<arr[a]))continue;
dyn+=f(a,mask+(1<<arr[a]));
}
return dyn;
}
int main()
{
scanf("%lld %lld %lld",&n,&m,&k);
for(LL a=1;a<=n;a++)
{
scanf("%lld",&arr[a]);
arr[a]--;
}
for(LL a=1;a<=m;a++)
{
LL x,y;
scanf("%lld %lld",&x,&y);
adj[x].push_back(y);
adj[y].push_back(x);
}
LL res=0;
for(LL a=1;a<=n;a++)
{
res+=f(a,1LL<<arr[a]);
// printf("%lld : %lld\n",a,res);
}
printf("%lld\n",res-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... |