Submission #213442

#TimeUsernameProblemLanguageResultExecution timeMemory
213442MKopchevPaths (BOI18_paths)C++14
100 / 100
420 ms54392 KiB
#include<bits/stdc++.h> using namespace std; const int nmax=3e5+42; long long dp[32][nmax]; int colour[nmax]; vector<int> adj[nmax]; int n,m,k; long long rec(int remain,int pos) { if(remain==0)return 1; if(dp[remain][pos])return dp[remain][pos]; long long ret=1;//alone for(auto nxt:adj[pos]) if((remain&(1<<colour[nxt])))ret=ret+rec(remain-(1<<colour[nxt]),nxt); dp[remain][pos]=ret; return ret; } int main() { scanf("%i%i%i",&n,&m,&k); for(int i=1;i<=n;i++) { scanf("%i",&colour[i]); colour[i]--; } int u,v; for(int i=1;i<=m;i++) { scanf("%i%i",&u,&v); adj[u].push_back(v); adj[v].push_back(u); } long long ret=0; for(int i=1;i<=n;i++) ret=ret+rec((1<<k)-1-(1<<colour[i]),i)-1; printf("%lld\n",ret); return 0; }

Compilation message (stderr)

paths.cpp: In function 'int main()':
paths.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i%i",&n,&m,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~
paths.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i",&colour[i]);
         ~~~~~^~~~~~~~~~~~~~~~~
paths.cpp:35:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i%i",&u,&v);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...