Submission #146324

#TimeUsernameProblemLanguageResultExecution timeMemory
146324MvCPaths (BOI18_paths)C++11
100 / 100
467 ms57992 KiB
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include<bits/stdc++.h> //#include "boxes.h" #define rc(x) return cout<<x<<endl,0 #define pb push_back #define mkp make_pair #define in insert #define er erase #define fd find #define fr first #define sc second typedef long long ll; typedef long double ld; const ll INF=0x3f3f3f3f3f3f3f3f; const ll llinf=(1LL<<62); const int inf=(1<<30); const int nmax=3e5+50; const int mod=1e9+7; using namespace std; int n,m,k,i,j,t,x,y,c[nmax]; ll f[50][nmax],rs; vector<int>a[nmax],vc[7]; int main() { //freopen("sol.in","r",stdin); //freopen("sol.out","w",stdout); //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); cin>>n>>m>>k; for(i=1;i<=n;i++) { cin>>c[i]; c[i]--; vc[c[i]].pb(i); } while(m--) { cin>>x>>y; a[x].pb(y); a[y].pb(x); } for(i=0;i<k;i++) { for(j=0;j<vc[i].size();j++) { x=vc[i][j]; f[1<<i][x]=1; } } for(i=0;i<(1<<k);i++) { for(j=1;j<=n;j++) { if(!f[i][j])continue; for(t=0;t<a[j].size();t++) { x=a[j][t]; if(i&(1<<c[x]))continue; f[i|(1<<c[x])][x]+=f[i][j]; } rs+=f[i][j]; } } cout<<rs-n<<endl; return 0; }

Compilation message (stderr)

paths.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
paths.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
 
paths.cpp: In function 'int main()':
paths.cpp:46:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(j=0;j<vc[i].size();j++)
           ~^~~~~~~~~~~~~
paths.cpp:57:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(t=0;t<a[j].size();t++)
            ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...