제출 #1341395

#제출 시각아이디문제언어결과실행 시간메모리
1341395dead0neAmusement Park (CEOI19_amusementpark)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#define int long long
#define ii pair<int, int>
#define st first
#define nd second
#define vi vector<int>
#define pb push_back
#define spc << " " <<
#define MX 300005
#define MOD 998244353
#define inf 1e15
using namespace std;

int dp[1<<18], popcount[1<<18], ind[1<<18];
int add(int x, int y){
    if(x+y>=MOD) return x+y-MOD;
    return x+y;
}

int subt(int x, int y){
    if(x-y<0) return x-y+MOD;
    return x-y;
}

int mult(int x, int y){
    return (x*y)%MOD;
}

void solve(){
    int n,m; cin >> n >> m;
    int edg[n]{};
    for(int i=1; i<=m; i++){
        int a,b; cin >> a >> b; a--; b--;
        edg[a]|=(1<<b);
        edg[b]|=(1<<a);
    }
    popcount[0]=0;
    dp[0]=ind[0]=1;
    for(int i=1; i<(1<<n); i++){
        int k=(i&-i);
        popcount[i]=popcount[i^k]+1;
        ind[i]=0;
        //cerr << "wow" spc i spc k spc (i^k) spc ind[i^k] spc edg[__lg(k)] << endl;
        if(ind[i^k]==1 && (edg[__lg(k)]&(i^k))==0) ind[i]=1;
    }
    for(int mask=1; mask<(1<<n); mask++){
        dp[mask]=0;
        for(int i=mask; i>0; i=(i-1)&mask){
            int sub=i^mask;
            if(!ind[i]) continue;
            if(popcount[i]&1){ //tek, poz
                dp[mask]=add(dp[mask], dp[sub]);
            }
            else{ //cift, neg
                dp[mask]=subt(dp[mask], dp[sub]);
            }
        }
    }
    cout << mult(mult(m, dp[(1<<n)-1]), 499122177) << endl;
}

signed main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    #ifdef Local
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
    #endif
    solve();
}

컴파일 시 표준 에러 (stderr) 메시지

amusementpark.cpp: In function 'void solve()':
amusementpark.cpp:37:5: error: reference to 'popcount' is ambiguous
   37 |     popcount[0]=0;
      |     ^~~~~~~~
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:14:16: note:                 'long long int popcount [262144]'
   14 | int dp[1<<18], popcount[1<<18], ind[1<<18];
      |                ^~~~~~~~
amusementpark.cpp:41:9: error: reference to 'popcount' is ambiguous
   41 |         popcount[i]=popcount[i^k]+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:14:16: note:                 'long long int popcount [262144]'
   14 | int dp[1<<18], popcount[1<<18], ind[1<<18];
      |                ^~~~~~~~
amusementpark.cpp:41:21: error: reference to 'popcount' is ambiguous
   41 |         popcount[i]=popcount[i^k]+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:14:16: note:                 'long long int popcount [262144]'
   14 | int dp[1<<18], popcount[1<<18], ind[1<<18];
      |                ^~~~~~~~
amusementpark.cpp:51:16: error: reference to 'popcount' is ambiguous
   51 |             if(popcount[i]&1){ //tek, poz
      |                ^~~~~~~~
/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:14:16: note:                 'long long int popcount [262144]'
   14 | int dp[1<<18], popcount[1<<18], ind[1<<18];
      |                ^~~~~~~~