답안 #1005109

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005109 2024-06-22T07:15:48 Z pcc Council (JOI23_council) C++17
56 / 100
4000 ms 8116 KB
#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 = 20;
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;

}

namespace SPEC{
	void GO(){
		for(int id = 1;id<=N;id++){

			for(int i = 0;i<M;i++){
				if((1<<i)&arr[id])cnt[i]--;
			}
			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 = 1;i<=N;i++)if(i != id)c = min(c,__builtin_popcount(mask&arr[i]));
			ans -= c;
			for(int i = 0;i<M;i++)if((1<<i)&arr[id])cnt[i]++;
			cout<<ans<<'\n';

		}
		return;
	}
}

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]]++;
	}
	if(N<=5000){
		SPEC::GO();
		return 0;
	}
	for(int i = 1;i<=N;i++)cout<<f(i)<<'\n';
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 1 ms 6744 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6616 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 4564 KB Output is correct
15 Correct 1 ms 4528 KB Output is correct
16 Correct 1 ms 4440 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4700 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4556 KB Output is correct
29 Correct 0 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4560 KB Output is correct
43 Correct 1 ms 4440 KB Output is correct
44 Correct 1 ms 4440 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 1 ms 4444 KB Output is correct
48 Correct 1 ms 4444 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 1 ms 6744 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6616 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 4564 KB Output is correct
15 Correct 1 ms 4528 KB Output is correct
16 Correct 1 ms 4440 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4700 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4556 KB Output is correct
29 Correct 0 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4560 KB Output is correct
43 Correct 1 ms 4440 KB Output is correct
44 Correct 1 ms 4440 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 1 ms 4444 KB Output is correct
48 Correct 1 ms 4444 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
51 Correct 9 ms 4700 KB Output is correct
52 Correct 8 ms 2396 KB Output is correct
53 Correct 9 ms 6748 KB Output is correct
54 Correct 9 ms 6748 KB Output is correct
55 Correct 8 ms 4444 KB Output is correct
56 Correct 8 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 34 ms 5876 KB Output is correct
3 Correct 35 ms 3672 KB Output is correct
4 Correct 28 ms 4688 KB Output is correct
5 Correct 40 ms 5980 KB Output is correct
6 Correct 27 ms 5664 KB Output is correct
7 Correct 47 ms 5008 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 7 ms 4580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 34 ms 5876 KB Output is correct
3 Correct 35 ms 3672 KB Output is correct
4 Correct 28 ms 4688 KB Output is correct
5 Correct 40 ms 5980 KB Output is correct
6 Correct 27 ms 5664 KB Output is correct
7 Correct 47 ms 5008 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 7 ms 4580 KB Output is correct
18 Correct 1 ms 4440 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 270 ms 8116 KB Output is correct
21 Correct 201 ms 5072 KB Output is correct
22 Correct 182 ms 5200 KB Output is correct
23 Correct 237 ms 5568 KB Output is correct
24 Correct 224 ms 2900 KB Output is correct
25 Correct 346 ms 5072 KB Output is correct
26 Correct 343 ms 5296 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 0 ms 4444 KB Output is correct
30 Correct 0 ms 4472 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 0 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 0 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 34 ms 5876 KB Output is correct
3 Correct 35 ms 3672 KB Output is correct
4 Correct 28 ms 4688 KB Output is correct
5 Correct 40 ms 5980 KB Output is correct
6 Correct 27 ms 5664 KB Output is correct
7 Correct 47 ms 5008 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 7 ms 4580 KB Output is correct
18 Correct 1 ms 4440 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 270 ms 8116 KB Output is correct
21 Correct 201 ms 5072 KB Output is correct
22 Correct 182 ms 5200 KB Output is correct
23 Correct 237 ms 5568 KB Output is correct
24 Correct 224 ms 2900 KB Output is correct
25 Correct 346 ms 5072 KB Output is correct
26 Correct 343 ms 5296 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 0 ms 4444 KB Output is correct
30 Correct 0 ms 4472 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 0 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 0 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 2162 ms 5052 KB Output is correct
48 Correct 1112 ms 5200 KB Output is correct
49 Correct 1125 ms 5204 KB Output is correct
50 Correct 1904 ms 5328 KB Output is correct
51 Correct 1975 ms 3052 KB Output is correct
52 Correct 2971 ms 5204 KB Output is correct
53 Correct 3053 ms 5328 KB Output is correct
54 Correct 1 ms 4444 KB Output is correct
55 Correct 1 ms 4444 KB Output is correct
56 Correct 1 ms 4444 KB Output is correct
57 Correct 1 ms 4444 KB Output is correct
58 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 34 ms 5876 KB Output is correct
3 Correct 35 ms 3672 KB Output is correct
4 Correct 28 ms 4688 KB Output is correct
5 Correct 40 ms 5980 KB Output is correct
6 Correct 27 ms 5664 KB Output is correct
7 Correct 47 ms 5008 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4444 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 7 ms 4580 KB Output is correct
18 Correct 1 ms 4440 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 270 ms 8116 KB Output is correct
21 Correct 201 ms 5072 KB Output is correct
22 Correct 182 ms 5200 KB Output is correct
23 Correct 237 ms 5568 KB Output is correct
24 Correct 224 ms 2900 KB Output is correct
25 Correct 346 ms 5072 KB Output is correct
26 Correct 343 ms 5296 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4444 KB Output is correct
29 Correct 0 ms 4444 KB Output is correct
30 Correct 0 ms 4472 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 0 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 0 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4444 KB Output is correct
43 Correct 1 ms 4444 KB Output is correct
44 Correct 1 ms 4444 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 2162 ms 5052 KB Output is correct
48 Correct 1112 ms 5200 KB Output is correct
49 Correct 1125 ms 5204 KB Output is correct
50 Correct 1904 ms 5328 KB Output is correct
51 Correct 1975 ms 3052 KB Output is correct
52 Correct 2971 ms 5204 KB Output is correct
53 Correct 3053 ms 5328 KB Output is correct
54 Correct 1 ms 4444 KB Output is correct
55 Correct 1 ms 4444 KB Output is correct
56 Correct 1 ms 4444 KB Output is correct
57 Correct 1 ms 4444 KB Output is correct
58 Correct 1 ms 4444 KB Output is correct
59 Execution timed out 4061 ms 4800 KB Time limit exceeded
60 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 1 ms 6744 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6616 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6488 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 1 ms 4564 KB Output is correct
15 Correct 1 ms 4528 KB Output is correct
16 Correct 1 ms 4440 KB Output is correct
17 Correct 1 ms 4440 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 4444 KB Output is correct
22 Correct 1 ms 4444 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 1 ms 4700 KB Output is correct
25 Correct 1 ms 4444 KB Output is correct
26 Correct 1 ms 4444 KB Output is correct
27 Correct 1 ms 4444 KB Output is correct
28 Correct 1 ms 4556 KB Output is correct
29 Correct 0 ms 4444 KB Output is correct
30 Correct 1 ms 4444 KB Output is correct
31 Correct 1 ms 4444 KB Output is correct
32 Correct 1 ms 4444 KB Output is correct
33 Correct 1 ms 4444 KB Output is correct
34 Correct 1 ms 4444 KB Output is correct
35 Correct 1 ms 4444 KB Output is correct
36 Correct 1 ms 4444 KB Output is correct
37 Correct 1 ms 4444 KB Output is correct
38 Correct 1 ms 4444 KB Output is correct
39 Correct 1 ms 4444 KB Output is correct
40 Correct 1 ms 4444 KB Output is correct
41 Correct 1 ms 4444 KB Output is correct
42 Correct 1 ms 4560 KB Output is correct
43 Correct 1 ms 4440 KB Output is correct
44 Correct 1 ms 4440 KB Output is correct
45 Correct 1 ms 4444 KB Output is correct
46 Correct 1 ms 4444 KB Output is correct
47 Correct 1 ms 4444 KB Output is correct
48 Correct 1 ms 4444 KB Output is correct
49 Correct 1 ms 4444 KB Output is correct
50 Correct 1 ms 4444 KB Output is correct
51 Correct 9 ms 4700 KB Output is correct
52 Correct 8 ms 2396 KB Output is correct
53 Correct 9 ms 6748 KB Output is correct
54 Correct 9 ms 6748 KB Output is correct
55 Correct 8 ms 4444 KB Output is correct
56 Correct 8 ms 4444 KB Output is correct
57 Correct 1 ms 4444 KB Output is correct
58 Correct 34 ms 5876 KB Output is correct
59 Correct 35 ms 3672 KB Output is correct
60 Correct 28 ms 4688 KB Output is correct
61 Correct 40 ms 5980 KB Output is correct
62 Correct 27 ms 5664 KB Output is correct
63 Correct 47 ms 5008 KB Output is correct
64 Correct 1 ms 2392 KB Output is correct
65 Correct 1 ms 4444 KB Output is correct
66 Correct 1 ms 4444 KB Output is correct
67 Correct 1 ms 4444 KB Output is correct
68 Correct 1 ms 4444 KB Output is correct
69 Correct 1 ms 2396 KB Output is correct
70 Correct 1 ms 4444 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 1 ms 4444 KB Output is correct
73 Correct 7 ms 4580 KB Output is correct
74 Correct 1 ms 4440 KB Output is correct
75 Correct 0 ms 2396 KB Output is correct
76 Correct 270 ms 8116 KB Output is correct
77 Correct 201 ms 5072 KB Output is correct
78 Correct 182 ms 5200 KB Output is correct
79 Correct 237 ms 5568 KB Output is correct
80 Correct 224 ms 2900 KB Output is correct
81 Correct 346 ms 5072 KB Output is correct
82 Correct 343 ms 5296 KB Output is correct
83 Correct 1 ms 4444 KB Output is correct
84 Correct 1 ms 4444 KB Output is correct
85 Correct 0 ms 4444 KB Output is correct
86 Correct 0 ms 4472 KB Output is correct
87 Correct 1 ms 4444 KB Output is correct
88 Correct 0 ms 4444 KB Output is correct
89 Correct 1 ms 4444 KB Output is correct
90 Correct 0 ms 4444 KB Output is correct
91 Correct 1 ms 4444 KB Output is correct
92 Correct 1 ms 4444 KB Output is correct
93 Correct 1 ms 4444 KB Output is correct
94 Correct 1 ms 4444 KB Output is correct
95 Correct 1 ms 4444 KB Output is correct
96 Correct 1 ms 4444 KB Output is correct
97 Correct 1 ms 4444 KB Output is correct
98 Correct 1 ms 4444 KB Output is correct
99 Correct 1 ms 4444 KB Output is correct
100 Correct 1 ms 4444 KB Output is correct
101 Correct 1 ms 4444 KB Output is correct
102 Correct 1 ms 4444 KB Output is correct
103 Correct 2162 ms 5052 KB Output is correct
104 Correct 1112 ms 5200 KB Output is correct
105 Correct 1125 ms 5204 KB Output is correct
106 Correct 1904 ms 5328 KB Output is correct
107 Correct 1975 ms 3052 KB Output is correct
108 Correct 2971 ms 5204 KB Output is correct
109 Correct 3053 ms 5328 KB Output is correct
110 Correct 1 ms 4444 KB Output is correct
111 Correct 1 ms 4444 KB Output is correct
112 Correct 1 ms 4444 KB Output is correct
113 Correct 1 ms 4444 KB Output is correct
114 Correct 1 ms 4444 KB Output is correct
115 Execution timed out 4061 ms 4800 KB Time limit exceeded
116 Halted 0 ms 0 KB -