QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#604565 | #6336. Council | Dimash# | 0 | 3ms | 9748kb | C++23 | 1.7kb | 2024-10-02 12:05:34 | 2024-10-02 12:05:35 |
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 12, MOD = (int)1e9 + 7;
int n, m, x[N], c[N], a[N][20];
vector<int> g[(1 << 20) + 1];
vector<pair<int, int>> b;
void test() {
cin >> n >> m;
for(int i = 1; i <= n; i++) {
for(int j = 0; j < m; j++) {
cin >> a[i][j];
if(a[i][j]) {
x[i] |= (1 << j);
c[j]++;
}
}
g[x[i]].push_back(i);
b.push_back({__builtin_popcount(x[i]), i});
}
sort(b.begin(), b.end());
vector<int> f;
while(!b.empty() && b.back().first != b[0].first) {
f.push_back(b.back().second);
b.pop_back();
}
reverse(f.begin(), f.end());
for(int i = 0; i < min((int)f.size(), 2); i++) {
b.push_back({0, f[i]});
}
// cout << (int)b.size() << '\n';
int val = n / 2;
for(int i = 1; i <= n; i++) {
int res = 0, t = 0;
for(int j = 0; j < m; j++) {
if(c[j] - a[i][j] > val) {
res++;
} else if(c[j] - a[i][j] == val) {
t |= (1 << j);
res++;
}
}
int mn = __builtin_popcount(t);
// cout << res << ' ' << mn << '\n';
for(auto [j, y]:b) {
if(y == i) continue;
int _t = (t & x[y]);
mn = min(mn, __builtin_popcount(_t));
// cout << mn << '\n';
}
cout << res - mn << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t = 1;
// cin >> t;
while(t--)
test();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 8
Accepted
time: 2ms
memory: 7628kb
input:
38 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 ...
output:
18 18 1 1 18 18 18 1 1 18 18 18 18 18 18 18 1 18 18 1 18 1 1 18 1 1 18 18 1 1 1 18 1 1 1 18 1 1
result:
ok 38 numbers
Test #2:
score: 8
Accepted
time: 3ms
memory: 9748kb
input:
300 20 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ...
result:
ok 300 numbers
Test #3:
score: 8
Accepted
time: 2ms
memory: 7900kb
input:
5 20 0 0 0 1 1 0 0 0 1 1 0 1 1 0 0 1 1 1 0 0 1 0 1 0 1 0 1 0 1 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 0 1 0 1 1 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 1 1 1 0 0 0 1 1 1 0 0 1 0 1 1
output:
7 9 9 8 9
result:
ok 5 number(s): "7 9 9 8 9"
Test #4:
score: 0
Wrong Answer
time: 2ms
memory: 7764kb
input:
20 20 1 0 1 1 0 1 1 1 1 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 0 1 0 0 1 1 1 0 1 1 0 0 1 0 1 0 1 0 0 0 1 0 0 0 1 1 0 1 1 0 0 0 0 0 1 1 0 1 0 1 1 1 1 1 0 1 0 1 0 1 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 1 1 0 1 1 0 0 0 1 1 1 0 0 0 0 0 1 0 1 1 0 1 1 0 0 1 1 1 1 1 0 1 1 1 1 0 1 0 0 0 0 0 1 1 0 1 1 0 1 0 0 0 0 1 0 0 0 ...
output:
11 13 12 12 12 13 12 13 10 12 12 12 10 10 12 13 11 13 13 10
result:
wrong answer 1st numbers differ - expected: '12', found: '11'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Time Limit Exceeded
Test #53:
score: 0
Time Limit Exceeded
input:
300000 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #1:
0%