Submission #1307157

#TimeUsernameProblemLanguageResultExecution timeMemory
1307157NipphitchAmusement Park (CEOI19_amusementpark)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N=18; const int mod=998244353; int n,m,adj[N+1],popcount[(1<<N)+1],ar[(1<<N)+1],id[(1<<N)+1],dp[(1<<N)+1],ans; bool inde[(1<<N)+1]; signed main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i=1;i<=m;i++){ int u,v; cin >> u >> v; u--,v--; adj[u]|=(1<<v); adj[v]|=(1<<u); } for(int i=0;i<n;i++) id[(1<<i)]=i; for(int mask=0;mask<(1<<n);mask++){ popcount[mask]=__builtin_popcount(mask); if(popcount[mask]%2==1) ar[mask]=1; else ar[mask]=-1; } inde[0]=true; for(int mask=1;mask<(1<<n);mask++){ if(inde[mask&(mask-1)] && !(adj[id[mask&(-mask)]]&(mask&(mask-1)))){ inde[mask]=true; } } dp[0]=1; for(int mask=1;mask<(1<<n);mask++){ for(int sub=mask;sub;sub=(sub-1)&mask){ if(inde[sub]){ dp[mask]=(dp[mask]+ar[sub]*dp[mask^sub])%mod; } } } ans=dp[(1<<n)-1]; if(ans<0) ans+=mod; ans=(ans*m)%mod; ans=(ans*(mod+1)/2)%mod; cout << ans; }

Compilation message (stderr)

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:24:9: error: reference to 'popcount' is ambiguous
   24 |         popcount[mask]=__builtin_popcount(mask);
      |         ^~~~~~~~
In file included from /usr/include/c++/13/bits/stl_algobase.h:76,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from amusementpark.cpp:1:
/usr/include/c++/13/bit:426:5: note: candidates are: 'template<class _Tp> constexpr std::_If_is_unsigned_integer<_Tp, int> std::popcount(_Tp)'
  426 |     popcount(_Tp __x) noexcept
      |     ^~~~~~~~
amusementpark.cpp:7:18: note:                 'long long int popcount [262145]'
    7 | int n,m,adj[N+1],popcount[(1<<N)+1],ar[(1<<N)+1],id[(1<<N)+1],dp[(1<<N)+1],ans;
      |                  ^~~~~~~~
amusementpark.cpp:25:12: error: reference to 'popcount' is ambiguous
   25 |         if(popcount[mask]%2==1) ar[mask]=1;
      |            ^~~~~~~~
/usr/include/c++/13/bit:426:5: note: candidates are: 'template<class _Tp> constexpr std::_If_is_unsigned_integer<_Tp, int> std::popcount(_Tp)'
  426 |     popcount(_Tp __x) noexcept
      |     ^~~~~~~~
amusementpark.cpp:7:18: note:                 'long long int popcount [262145]'
    7 | int n,m,adj[N+1],popcount[(1<<N)+1],ar[(1<<N)+1],id[(1<<N)+1],dp[(1<<N)+1],ans;
      |                  ^~~~~~~~