Submission #206892

#TimeUsernameProblemLanguageResultExecution timeMemory
206892okoPaths (BOI18_paths)C++14
23 / 100
3076 ms14072 KiB
#include<bits/stdc++.h> using namespace std; const long long mod=1e9+7; long long n,m,k,a[300005],ans; vector<int>gr[300005]; long long dfs(int x,int mask) { long long num=0; for(int i=0;i<gr[x].size();i++) { int u=gr[x][i]; if((mask&(1<<a[u])))continue; num+=dfs(u,(mask|(1<<a[u]))); } return num+1; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen(".in","r",stdin); //freopen(".out","w",stdout); cin>>n>>m>>k; for(int i=1;i<=n;i++)cin>>a[i]; for(int i=0;i<m;i++) { int x,y; cin>>x>>y; gr[x].push_back(y); gr[y].push_back(x); } for(int i=1;i<=n;i++)ans+=dfs(i,(1<<a[i])); cout<<ans-n; }

Compilation message (stderr)

paths.cpp: In function 'long long int dfs(int, int)':
paths.cpp:9:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<gr[x].size();i++)
                 ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...