이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define sz(v) int(v.size())
#define ar array
typedef long long ll;
const int N = 3e5+10, MOD = 1e9+7;
const int M = 21;
int n, m, a[N], cnt[M];
void solve() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int x; cin >> x;
a[i] |= x << j;
cnt[j] += x;
}
}
for (int i = 0; i < n; i++) {
int base = 0;
int bad = 0;
for (int j = 0; j < m; j++) {
int need = n / 2;
int has = cnt[j] - ((a[i] >> j) & 1);
if (has != need) {
base += has > need;
continue;
}
bad |= 1 << j;
base++;
}
int ans = m;
for (int j = 0; j < n; j++) if (j != i) ans = min(ans, __builtin_popcount(a[j] & bad));
cout << base - ans << '\n';
}
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int T = 1;
// cin >> T;
while (T--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |