Submission #1090850

# Submission time Handle Problem Language Result Execution time Memory
1090850 2024-09-18T22:41:02 Z ArtistWall Amusement Park (CEOI19_amusementpark) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

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];
long long f[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]) { f[i] = (f[i] + arg[j] * f[i ^ j]) % M; }
		}
	}
	f[(1 << n) - 1] = (f[(1 << n) - 1] + M) % M;
	cout << f[(1 << n) - 1] * m % M * ((M + 1) / 2) % M;
	return 0;
}

Compilation message

amusementpark.cpp: In function 'int main()':
amusementpark.cpp:26:3: error: reference to 'arg' is ambiguous
   26 |   arg[i] = (popcount[i] % 2) * 2 - 1;
      |   ^~~
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from amusementpark.cpp:1:
/usr/include/c++/10/complex:1848:5: note: candidates are: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp>::__type std::arg(_Tp)'
 1848 |     arg(_Tp __x)
      |     ^~~
/usr/include/c++/10/complex:652:5: note:                 'template<class _Tp> _Tp std::arg(const std::complex<_Tp>&)'
  652 |     arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
      |     ^~~
amusementpark.cpp:9:5: note:                 'int arg [262144]'
    9 | int arg[1 << N];
      |     ^~~
amusementpark.cpp:37:38: error: reference to 'arg' is ambiguous
   37 |    if (indepset[j]) { f[i] = (f[i] + arg[j] * f[i ^ j]) % M; }
      |                                      ^~~
In file included from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from amusementpark.cpp:1:
/usr/include/c++/10/complex:1848:5: note: candidates are: 'template<class _Tp> typename __gnu_cxx::__promote<_Tp>::__type std::arg(_Tp)'
 1848 |     arg(_Tp __x)
      |     ^~~
/usr/include/c++/10/complex:652:5: note:                 'template<class _Tp> _Tp std::arg(const std::complex<_Tp>&)'
  652 |     arg(const complex<_Tp>& __z) { return __complex_arg(__z.__rep()); }
      |     ^~~
amusementpark.cpp:9:5: note:                 'int arg [262144]'
    9 | int arg[1 << N];
      |     ^~~