Submission #445534

#TimeUsernameProblemLanguageResultExecution timeMemory
445534cpp219Paths (BOI18_paths)C++14
100 / 100
511 ms102748 KiB
#pragma GCC optimization O2 #pragma GCC optimization "unroll-loop" #pragma target ("avx2") #include <bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 3e5 + 9; const ll Log2 = 20; const ll inf = 1e9 + 7; vector<ll> g[N]; ll n,m,k,a[N],x,y,dp[N][33],ans; bool bit(ll x,ll i){ return (x >> i) & 1; } ll f(ll node,ll mask){ if (dp[node][mask] != -1) return dp[node][mask]; ll have = __builtin_popcount(mask); ll ans = (have > 1); for (auto i : g[node]){ if (bit(mask,a[i])) continue; ans += f(i,mask ^ (1 << a[i])); } return dp[node][mask] = ans; } int main(){ ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); #define task "tst" if (fopen(task".INP","r")){ freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } cin>>n>>m>>k; memset(dp,-1,sizeof(dp)); for (ll i = 1;i <= n;i++) cin>>a[i]; while(m--){ cin>>x>>y; g[x].push_back(y); g[y].push_back(x); } //cout<<f(1,(1 << a[1])); return 0; for (ll i = 1;i <= n;i++) ans += f(i,(1 << a[i])); cout<<ans; }

Compilation message (stderr)

paths.cpp:1: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    1 | #pragma GCC optimization O2
      | 
paths.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
paths.cpp:3: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    3 | #pragma target ("avx2")
      | 
paths.cpp: In function 'int main()':
paths.cpp:38:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...