Submission #379902

#TimeUsernameProblemLanguageResultExecution timeMemory
379902FidiskPaths (BOI18_paths)C++14
100 / 100
571 ms131056 KiB
#include <bits/stdc++.h> using namespace std; #define oo 1e12 #define fi first #define se second #define sp(iiii) setprecision(iiii) #define IO ios_base::sync_with_stdio(false); cin.tie(0) #define ms(aaaa,xxxx) memset(aaaa,xxxx,sizeof(aaaa)) #define cntbit(xxxx) __builtin_popcount(xxxx) #define getbit(xxxx,aaaa) ((xxxx>>(aaaa-1))&1) typedef long double ld; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<pair<int,int>,int> piii; typedef pair<long long,long long> pll; typedef pair<pair<long long,long long>,long long> plll; typedef pair<pair<long long,long long>,pair<long long,long long>> pllll; typedef pair<pair<long long,long long>,bool> pllb; const ll base=361; const ll mod=1e9+7; const ld eps=1e-5; ll n,m,k,i,j,l,ii,a[500009],f[500009][43],res,u,v; vector<ll> g[500009],t[509]; int main(){ IO; cin>>n>>m>>k; for (i=1;i<=n;i++) { cin>>a[i]; } for (i=1;i<=m;i++) { cin>>u>>v; g[u].push_back(v); g[v].push_back(u); } for (i=1;i<=n;i++) { f[i][(1<<(a[i]-1))]=1; } //cout<<(1<<k)<<'\n'; for (i=1;i<(1<<k);i++) { t[cntbit(i)].push_back(i); } for (i=2;i<=k;i++) { for (j=0;j<t[i].size();j++) { //cout<<i<<' '<<t[i][j]<<'\n'; for (l=1;l<=n;l++) { if ((t[i][j]&(1<<(a[l]-1)))!=0) { for (ii=0;ii<g[l].size();ii++) { //cout<<i<<' '<<l<<' '<<t[i][j]<<" - "<<g[l][ii]<<' '<<(t[i][j]^(1<<(a[l]-1)))<<'\n'; f[l][t[i][j]]+=f[g[l][ii]][t[i][j]^(1<<(a[l]-1))]; } } } } } for (i=0;i<(1<<k);i++) { if (cntbit(i)>=2) { for (j=1;j<=n;j++) { res+=f[j][i]; } } } cout<<res<<'\n'; }

Compilation message (stderr)

paths.cpp: In function 'int main()':
paths.cpp:49:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for (j=0;j<t[i].size();j++) {
      |                  ~^~~~~~~~~~~~
paths.cpp:53:33: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |                     for (ii=0;ii<g[l].size();ii++) {
      |                               ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...