Submission #208458

#TimeUsernameProblemLanguageResultExecution timeMemory
208458tleontest1Paths (BOI18_paths)C++14
100 / 100
623 ms118144 KiB
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; typedef long long lo; typedef pair< lo,lo > PII; #define fi first #define se second #define int long long #define mp make_pair #define pb push_back #define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define FOR for(int i=1;i<=n;i++) #define mid ((start+end)/2) #define ort ((bas+son)/2) const lo MAX = -1000000000000000000; const lo MIN = 1000000000000000000; const lo inf = 1000000000; const lo KOK = 100000; const lo LOG = 30; const lo li = 300005; const lo mod = 1000000007; int n,m,b[li],a[li],k,flag,t,dp[li][(1<<5)+3]; int cev; string s; map<vector<int>,int> mpp[li]; vector<int> v[li],vec; inline int dfs(int node,int ata,int mask){ int cevv=0; if(mask==(1<<5)-1)return 1; if(~dp[node][mask])return dp[node][mask]; if(mask!=(1<<0) && mask!=(1<<1) && mask!=(1<<2) && mask!=(1<<3) && mask!=(1<<4) && mask)cevv+=dfs(node,ata,(1<<5)-1); for(int i=0;i<(int)v[node].size();i++){ int go=v[node][i]; //~ if(go==ata)continue; //~ cevv+=dfs(go,node,mask); if((mask&(1<<(a[go]-1)))==0)cevv+=dfs(go,node,(mask|(1<<(a[go]-1)))); } return dp[node][mask]=cevv; } main(void){ scanf("%lld %lld %lld",&n,&m,&k); FOR scanf("%lld",&a[i]); for(int i=1;i<=m;i++){ int x,y; scanf("%lld %lld",&x,&y); v[x].pb(y); v[y].pb(x); } memset(dp,-1,sizeof(dp)); FOR{ cev+=dfs(i,0,(1<<(a[i]-1))); } printf("%lld\n",cev); return 0; }

Compilation message (stderr)

paths.cpp:51:10: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(void){
          ^
paths.cpp: In function 'int main()':
paths.cpp:53:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld %lld",&n,&m,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
paths.cpp:54:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  FOR scanf("%lld",&a[i]);
      ~~~~~^~~~~~~~~~~~~~
paths.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&x,&y);
   ~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...