Submission #872360

# Submission time Handle Problem Language Result Execution time Memory
872360 2023-11-13T00:59:12 Z MinaRagy06 Council (JOI23_council) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int a[300'005], cnt[21], dp[21][1 << 21][21];
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	int n, m;
	cin >> n >> m;
	int mx = 1 << m;
	for (int i = 0; i < n; i++) {
		for (int j = 0, x; j < m; j++) {
			cin >> x;
			a[i] |= x << j;
			cnt[j] += x;
		}
		dp[m][a[i]][0]++;
	}
	for (int i = m - 1; i >= 0; i--) {
		for (int msk = 0; msk < mx; msk++) {
			for (int j = 0; j <= m; j++) {
				if ((msk >> i) & 1) {
					if (j - 1 >= 0) dp[i][msk][j] += dp[i + 1][msk][j - 1];
					dp[i][msk][j] += dp[i + 1][msk ^ (1 << i)][j];
				} else {
					dp[i][msk][j] += dp[i + 1][msk][j];
					dp[i][msk][j] += dp[i + 1][msk ^ (1 << i)][j];
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) cnt[j] -= (a[i] >> j) & 1;
		int msk = 0, gud = 0;
		for (int j = 0; j < m; j++) {
			if (cnt[j] == n / 2) {
				msk |= 1 << j;
			} else if (cnt[j] > n / 2) {
				gud++;
			}
		}
		int cur = __builtin_popcount(a[i] & msk), mn = m;
		for (int k = 0; k <= m; k++) {
			if (dp[0][msk][k] > 1 || (dp[0][msk][k] == 1 && cur != k)) {
				mn = k;
				break;
			}
		}
		cout << gud + __builtin_popcount(msk) - mn << '\n';
		for (int j = 0; j < m; j++) cnt[j] += (a[i] >> j) & 1;
	}
	return 0;
}

Compilation message

/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status