#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,popcnt,sse4")
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
const int mxn = 3e5+10;
const int B = 15;
int arr[mxn];
int dp[1<<B];
int N,M;
int cnt[mxn];
int f(int id){
for(int i = 0;i<M;i++){
if((1<<i)&arr[id])cnt[i]--;
}
dp[arr[id]]--;
int mask = 0,ans = 0;
for(int i = 0;i<M;i++){
if(cnt[i] == N/2)mask|=1<<i;
if(cnt[i] >= N/2)ans++;
}
int c = B;
for(int i = 0;i<(1<<M);i++)if(dp[i])c = min(c,__builtin_popcount(mask&i));
ans -= c;
for(int i = 0;i<M;i++)if((1<<i)&arr[id])cnt[i]++;
dp[arr[id]]++;
return ans;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>N>>M;
for(int i = 1;i<=N;i++){
for(int j = 0;j<M;j++){
int k;
cin>>k;
if(k)cnt[j]++,arr[i]|=1<<j;
}
dp[arr[i]]++;
}
for(int i = 1;i<=N;i++)cout<<f(i)<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Runtime error |
2 ms |
4700 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Runtime error |
2 ms |
4700 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
35 ms |
4444 KB |
Output is correct |
3 |
Correct |
34 ms |
4188 KB |
Output is correct |
4 |
Correct |
27 ms |
3920 KB |
Output is correct |
5 |
Correct |
40 ms |
4432 KB |
Output is correct |
6 |
Correct |
27 ms |
3920 KB |
Output is correct |
7 |
Correct |
41 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2512 KB |
Output is correct |
16 |
Correct |
0 ms |
2512 KB |
Output is correct |
17 |
Correct |
1 ms |
2524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
35 ms |
4444 KB |
Output is correct |
3 |
Correct |
34 ms |
4188 KB |
Output is correct |
4 |
Correct |
27 ms |
3920 KB |
Output is correct |
5 |
Correct |
40 ms |
4432 KB |
Output is correct |
6 |
Correct |
27 ms |
3920 KB |
Output is correct |
7 |
Correct |
41 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2512 KB |
Output is correct |
16 |
Correct |
0 ms |
2512 KB |
Output is correct |
17 |
Correct |
1 ms |
2524 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
265 ms |
9008 KB |
Output is correct |
21 |
Correct |
201 ms |
8504 KB |
Output is correct |
22 |
Correct |
198 ms |
8532 KB |
Output is correct |
23 |
Correct |
254 ms |
9404 KB |
Output is correct |
24 |
Correct |
238 ms |
8940 KB |
Output is correct |
25 |
Correct |
315 ms |
9044 KB |
Output is correct |
26 |
Correct |
309 ms |
9044 KB |
Output is correct |
27 |
Correct |
0 ms |
2396 KB |
Output is correct |
28 |
Correct |
0 ms |
2396 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
0 ms |
2396 KB |
Output is correct |
32 |
Correct |
1 ms |
2396 KB |
Output is correct |
33 |
Correct |
1 ms |
2396 KB |
Output is correct |
34 |
Correct |
1 ms |
2396 KB |
Output is correct |
35 |
Correct |
0 ms |
2396 KB |
Output is correct |
36 |
Correct |
1 ms |
2396 KB |
Output is correct |
37 |
Correct |
0 ms |
2396 KB |
Output is correct |
38 |
Correct |
0 ms |
2396 KB |
Output is correct |
39 |
Correct |
0 ms |
2396 KB |
Output is correct |
40 |
Correct |
0 ms |
2396 KB |
Output is correct |
41 |
Correct |
1 ms |
2396 KB |
Output is correct |
42 |
Correct |
0 ms |
2396 KB |
Output is correct |
43 |
Correct |
0 ms |
2396 KB |
Output is correct |
44 |
Correct |
1 ms |
2396 KB |
Output is correct |
45 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
35 ms |
4444 KB |
Output is correct |
3 |
Correct |
34 ms |
4188 KB |
Output is correct |
4 |
Correct |
27 ms |
3920 KB |
Output is correct |
5 |
Correct |
40 ms |
4432 KB |
Output is correct |
6 |
Correct |
27 ms |
3920 KB |
Output is correct |
7 |
Correct |
41 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2512 KB |
Output is correct |
16 |
Correct |
0 ms |
2512 KB |
Output is correct |
17 |
Correct |
1 ms |
2524 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
265 ms |
9008 KB |
Output is correct |
21 |
Correct |
201 ms |
8504 KB |
Output is correct |
22 |
Correct |
198 ms |
8532 KB |
Output is correct |
23 |
Correct |
254 ms |
9404 KB |
Output is correct |
24 |
Correct |
238 ms |
8940 KB |
Output is correct |
25 |
Correct |
315 ms |
9044 KB |
Output is correct |
26 |
Correct |
309 ms |
9044 KB |
Output is correct |
27 |
Correct |
0 ms |
2396 KB |
Output is correct |
28 |
Correct |
0 ms |
2396 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
0 ms |
2396 KB |
Output is correct |
32 |
Correct |
1 ms |
2396 KB |
Output is correct |
33 |
Correct |
1 ms |
2396 KB |
Output is correct |
34 |
Correct |
1 ms |
2396 KB |
Output is correct |
35 |
Correct |
0 ms |
2396 KB |
Output is correct |
36 |
Correct |
1 ms |
2396 KB |
Output is correct |
37 |
Correct |
0 ms |
2396 KB |
Output is correct |
38 |
Correct |
0 ms |
2396 KB |
Output is correct |
39 |
Correct |
0 ms |
2396 KB |
Output is correct |
40 |
Correct |
0 ms |
2396 KB |
Output is correct |
41 |
Correct |
1 ms |
2396 KB |
Output is correct |
42 |
Correct |
0 ms |
2396 KB |
Output is correct |
43 |
Correct |
0 ms |
2396 KB |
Output is correct |
44 |
Correct |
1 ms |
2396 KB |
Output is correct |
45 |
Correct |
1 ms |
2396 KB |
Output is correct |
46 |
Correct |
1 ms |
2396 KB |
Output is correct |
47 |
Correct |
2434 ms |
11340 KB |
Output is correct |
48 |
Correct |
1263 ms |
10964 KB |
Output is correct |
49 |
Correct |
1248 ms |
10796 KB |
Output is correct |
50 |
Correct |
2464 ms |
11860 KB |
Output is correct |
51 |
Correct |
2721 ms |
11144 KB |
Output is correct |
52 |
Correct |
3375 ms |
11544 KB |
Output is correct |
53 |
Correct |
3209 ms |
11592 KB |
Output is correct |
54 |
Correct |
1 ms |
2396 KB |
Output is correct |
55 |
Correct |
1 ms |
2392 KB |
Output is correct |
56 |
Correct |
1 ms |
2396 KB |
Output is correct |
57 |
Correct |
0 ms |
2396 KB |
Output is correct |
58 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
35 ms |
4444 KB |
Output is correct |
3 |
Correct |
34 ms |
4188 KB |
Output is correct |
4 |
Correct |
27 ms |
3920 KB |
Output is correct |
5 |
Correct |
40 ms |
4432 KB |
Output is correct |
6 |
Correct |
27 ms |
3920 KB |
Output is correct |
7 |
Correct |
41 ms |
4432 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2512 KB |
Output is correct |
16 |
Correct |
0 ms |
2512 KB |
Output is correct |
17 |
Correct |
1 ms |
2524 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
265 ms |
9008 KB |
Output is correct |
21 |
Correct |
201 ms |
8504 KB |
Output is correct |
22 |
Correct |
198 ms |
8532 KB |
Output is correct |
23 |
Correct |
254 ms |
9404 KB |
Output is correct |
24 |
Correct |
238 ms |
8940 KB |
Output is correct |
25 |
Correct |
315 ms |
9044 KB |
Output is correct |
26 |
Correct |
309 ms |
9044 KB |
Output is correct |
27 |
Correct |
0 ms |
2396 KB |
Output is correct |
28 |
Correct |
0 ms |
2396 KB |
Output is correct |
29 |
Correct |
0 ms |
2396 KB |
Output is correct |
30 |
Correct |
1 ms |
2396 KB |
Output is correct |
31 |
Correct |
0 ms |
2396 KB |
Output is correct |
32 |
Correct |
1 ms |
2396 KB |
Output is correct |
33 |
Correct |
1 ms |
2396 KB |
Output is correct |
34 |
Correct |
1 ms |
2396 KB |
Output is correct |
35 |
Correct |
0 ms |
2396 KB |
Output is correct |
36 |
Correct |
1 ms |
2396 KB |
Output is correct |
37 |
Correct |
0 ms |
2396 KB |
Output is correct |
38 |
Correct |
0 ms |
2396 KB |
Output is correct |
39 |
Correct |
0 ms |
2396 KB |
Output is correct |
40 |
Correct |
0 ms |
2396 KB |
Output is correct |
41 |
Correct |
1 ms |
2396 KB |
Output is correct |
42 |
Correct |
0 ms |
2396 KB |
Output is correct |
43 |
Correct |
0 ms |
2396 KB |
Output is correct |
44 |
Correct |
1 ms |
2396 KB |
Output is correct |
45 |
Correct |
1 ms |
2396 KB |
Output is correct |
46 |
Correct |
1 ms |
2396 KB |
Output is correct |
47 |
Correct |
2434 ms |
11340 KB |
Output is correct |
48 |
Correct |
1263 ms |
10964 KB |
Output is correct |
49 |
Correct |
1248 ms |
10796 KB |
Output is correct |
50 |
Correct |
2464 ms |
11860 KB |
Output is correct |
51 |
Correct |
2721 ms |
11144 KB |
Output is correct |
52 |
Correct |
3375 ms |
11544 KB |
Output is correct |
53 |
Correct |
3209 ms |
11592 KB |
Output is correct |
54 |
Correct |
1 ms |
2396 KB |
Output is correct |
55 |
Correct |
1 ms |
2392 KB |
Output is correct |
56 |
Correct |
1 ms |
2396 KB |
Output is correct |
57 |
Correct |
0 ms |
2396 KB |
Output is correct |
58 |
Correct |
1 ms |
2392 KB |
Output is correct |
59 |
Execution timed out |
4057 ms |
12404 KB |
Time limit exceeded |
60 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Runtime error |
2 ms |
4700 KB |
Execution killed with signal 11 |
6 |
Halted |
0 ms |
0 KB |
- |