제출 #1129964

#제출 시각아이디문제언어결과실행 시간메모리
1129964mnbvcxz123Amusement Park (CEOI19_amusementpark)C++20
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; using ll=long long; const int N = 18; const int M = 998244353; int a[N]; bool indepset[1 << N]; int popcount[1 << N]; int arg[1 << N]; int nodeid[1 << N]; ll dp[1 << N]; int main() { int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) { int u, v; cin >> u >> v; u--; v--; a[u] |= 1 << v; a[v] |= 1 << u; } for (int i = 0; i < n; i++) { nodeid[1 << i] = i; } for (int i = 0; i < (1 << n); i++) { popcount[i] = popcount[i >> 1] + (i & 1); arg[i] = (popcount[i] % 2) * 2 - 1; } indepset[0] = 1; for (int i = 1; i < (1 << n); i++) { if (indepset[i & (i - 1)] && (a[nodeid[i & (-i)]] & (i & (i - 1))) == 0) { indepset[i] = true; } } f[0] = 1; for (int i = 1; i < (1 << n); i++) { for (int j = i; j; j = (j - 1) & i) { if (indepset[j]) { dp[i] = (dp[i] + arg[j] * dp[i ^ j]) % M; } } } dp[(1 << n) - 1] = (dp[(1 << n) - 1] + M) % M; cout << dp[(1 << n) - 1] * m % M * ((M + 1) / 2) % M; return 0; }

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

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:26:17: error: reference to 'popcount' is ambiguous
   26 |                 popcount[i] = popcount[i >> 1] + (i & 1);
      |                 ^~~~~~~~
In file included from /usr/include/c++/11/bits/align.h:35,
                 from /usr/include/c++/11/memory:72,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:82,
                 from amusementpark.cpp:1:
/usr/include/c++/11/bit:365:5: note: candidates are: 'template<class _Tp> constexpr std::_If_is_unsigned_integer<_Tp, int> std::popcount(_Tp)'
  365 |     popcount(_Tp __x) noexcept
      |     ^~~~~~~~
amusementpark.cpp:9:5: note:                 'int popcount [262144]'
    9 | int popcount[1 << N];
      |     ^~~~~~~~
amusementpark.cpp:26:31: error: reference to 'popcount' is ambiguous
   26 |                 popcount[i] = popcount[i >> 1] + (i & 1);
      |                               ^~~~~~~~
In file included from /usr/include/c++/11/bits/align.h:35,
                 from /usr/include/c++/11/memory:72,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:82,
                 from amusementpark.cpp:1:
/usr/include/c++/11/bit:365:5: note: candidates are: 'template<class _Tp> constexpr std::_If_is_unsigned_integer<_Tp, int> std::popcount(_Tp)'
  365 |     popcount(_Tp __x) noexcept
      |     ^~~~~~~~
amusementpark.cpp:9:5: note:                 'int popcount [262144]'
    9 | int popcount[1 << N];
      |     ^~~~~~~~
amusementpark.cpp:27:17: error: reference to 'arg' is ambiguous
   27 |                 arg[i] = (popcount[i] % 2) * 2 - 1;
      |                 ^~~
In file included from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from amusementpark.cpp:1:
/usr/include/c++/11/complex:1852:5: note: candidates are: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp>::__type std::arg(_Tp)'
 1852 |     arg(_Tp __x)
      |     ^~~
/usr/include/c++/11/complex:653:5: note:                 'template<class _Tp> _Tp std::arg(const std::complex<_Tp>&)'
  653 |     arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
      |     ^~~
amusementpark.cpp:10:5: note:                 'int arg [262144]'
   10 | int arg[1 << N];
      |     ^~~
amusementpark.cpp:27:27: error: reference to 'popcount' is ambiguous
   27 |                 arg[i] = (popcount[i] % 2) * 2 - 1;
      |                           ^~~~~~~~
In file included from /usr/include/c++/11/bits/align.h:35,
                 from /usr/include/c++/11/memory:72,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:82,
                 from amusementpark.cpp:1:
/usr/include/c++/11/bit:365:5: note: candidates are: 'template<class _Tp> constexpr std::_If_is_unsigned_integer<_Tp, int> std::popcount(_Tp)'
  365 |     popcount(_Tp __x) noexcept
      |     ^~~~~~~~
amusementpark.cpp:9:5: note:                 'int popcount [262144]'
    9 | int popcount[1 << N];
      |     ^~~~~~~~
amusementpark.cpp:35:9: error: 'f' was not declared in this scope
   35 |         f[0] = 1;
      |         ^
amusementpark.cpp:38:61: error: reference to 'arg' is ambiguous
   38 |                         if (indepset[j]) { dp[i] = (dp[i] + arg[j] * dp[i ^ j]) % M; }
      |                                                             ^~~
In file included from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from amusementpark.cpp:1:
/usr/include/c++/11/complex:1852:5: note: candidates are: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp>::__type std::arg(_Tp)'
 1852 |     arg(_Tp __x)
      |     ^~~
/usr/include/c++/11/complex:653:5: note:                 'template<class _Tp> _Tp std::arg(const std::complex<_Tp>&)'
  653 |     arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
      |     ^~~
amusementpark.cpp:10:5: note:                 'int arg [262144]'
   10 | int arg[1 << N];
      |     ^~~