답안 #919885

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
919885 2024-02-01T19:15:04 Z OAleksa Council (JOI23_council) C++14
33 / 100
4000 ms 19292 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
const int N = 3e5 + 69;
const int M = 21;
int a[N], cnt[M], n, m;
int t[M];
pair<int, int> bst[1 << M];
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
  	cin >> n >> m;
  	for (int i = 1;i <= n;i++) {
  		for (int j = 0;j < m;j++) {
  			int x;
  			cin >> x;
  			if (x > 0) {
  				a[i] += (1 << j);
  				cnt[j]++;
  			}
  		}
  	}
  	for (int i = 0;i < (1 << m);i++)
  		bst[i] = {i, i};
  	for (int i = 0;i < (1 << m);i++) {
  		for (int j = 1;j <= n;j++) {
  			int k = __builtin_popcount(a[j] & i);
  			if (k <= __builtin_popcount(bst[i].f & i)) {
  				bst[i].s = bst[i].f;
  				bst[i].f = a[j];
  			}
  			else if (k <= __builtin_popcount(bst[i].s & i))
  				bst[i].s = a[j];
  		}
  	}
  	for (int i = 1;i <= n;i++) {
  		int b = 0, ans = 0, c = 0;
  		for (int j = 0;j < m;j++) {
  			t[j] = cnt[j];
  			if (a[i] & (1 << j))
  				t[j]--;
  			if (t[j] == n / 2)
  				b += (1 << j), c++;
  			else if (t[j] > n / 2)
  				ans++;
  		}
  		if (bst[b].f == a[i])
  			ans += c - (__builtin_popcount(bst[b].s & b));
  		else
  			ans += c - (__builtin_popcount(bst[b].f & b));
  		cout << ans << '\n';
  	}
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 274 ms 19292 KB Output is correct
6 Correct 1221 ms 19088 KB Output is correct
7 Correct 36 ms 19032 KB Output is correct
8 Correct 163 ms 19032 KB Output is correct
9 Correct 2081 ms 19084 KB Output is correct
10 Correct 36 ms 19032 KB Output is correct
11 Correct 183 ms 19032 KB Output is correct
12 Correct 2029 ms 19084 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2648 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2504 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2552 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 3 ms 2396 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Correct 1 ms 2648 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 1 ms 2392 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 3 ms 2392 KB Output is correct
41 Correct 4 ms 4696 KB Output is correct
42 Correct 2 ms 4696 KB Output is correct
43 Correct 4 ms 4696 KB Output is correct
44 Correct 2 ms 4696 KB Output is correct
45 Correct 4 ms 4696 KB Output is correct
46 Correct 30 ms 4696 KB Output is correct
47 Correct 5 ms 4696 KB Output is correct
48 Correct 22 ms 4700 KB Output is correct
49 Correct 5 ms 4696 KB Output is correct
50 Correct 22 ms 4696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 274 ms 19292 KB Output is correct
6 Correct 1221 ms 19088 KB Output is correct
7 Correct 36 ms 19032 KB Output is correct
8 Correct 163 ms 19032 KB Output is correct
9 Correct 2081 ms 19084 KB Output is correct
10 Correct 36 ms 19032 KB Output is correct
11 Correct 183 ms 19032 KB Output is correct
12 Correct 2029 ms 19084 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2648 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2504 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2552 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 3 ms 2396 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Correct 1 ms 2648 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 1 ms 2392 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 3 ms 2392 KB Output is correct
41 Correct 4 ms 4696 KB Output is correct
42 Correct 2 ms 4696 KB Output is correct
43 Correct 4 ms 4696 KB Output is correct
44 Correct 2 ms 4696 KB Output is correct
45 Correct 4 ms 4696 KB Output is correct
46 Correct 30 ms 4696 KB Output is correct
47 Correct 5 ms 4696 KB Output is correct
48 Correct 22 ms 4700 KB Output is correct
49 Correct 5 ms 4696 KB Output is correct
50 Correct 22 ms 4696 KB Output is correct
51 Execution timed out 4049 ms 19032 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 45 ms 5200 KB Output is correct
3 Correct 47 ms 4176 KB Output is correct
4 Correct 35 ms 5688 KB Output is correct
5 Correct 54 ms 6228 KB Output is correct
6 Correct 35 ms 5712 KB Output is correct
7 Correct 56 ms 6236 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 45 ms 5200 KB Output is correct
3 Correct 47 ms 4176 KB Output is correct
4 Correct 35 ms 5688 KB Output is correct
5 Correct 54 ms 6228 KB Output is correct
6 Correct 35 ms 5712 KB Output is correct
7 Correct 56 ms 6236 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 2136 ms 11040 KB Output is correct
21 Correct 1172 ms 10452 KB Output is correct
22 Correct 1159 ms 10448 KB Output is correct
23 Correct 1316 ms 11300 KB Output is correct
24 Correct 1307 ms 8880 KB Output is correct
25 Correct 2164 ms 11040 KB Output is correct
26 Correct 2148 ms 11052 KB Output is correct
27 Correct 1 ms 2548 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 3 ms 2396 KB Output is correct
37 Correct 1 ms 2392 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 1 ms 2392 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 1 ms 2392 KB Output is correct
43 Correct 1 ms 2648 KB Output is correct
44 Correct 1 ms 2392 KB Output is correct
45 Correct 3 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 45 ms 5200 KB Output is correct
3 Correct 47 ms 4176 KB Output is correct
4 Correct 35 ms 5688 KB Output is correct
5 Correct 54 ms 6228 KB Output is correct
6 Correct 35 ms 5712 KB Output is correct
7 Correct 56 ms 6236 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 2136 ms 11040 KB Output is correct
21 Correct 1172 ms 10452 KB Output is correct
22 Correct 1159 ms 10448 KB Output is correct
23 Correct 1316 ms 11300 KB Output is correct
24 Correct 1307 ms 8880 KB Output is correct
25 Correct 2164 ms 11040 KB Output is correct
26 Correct 2148 ms 11052 KB Output is correct
27 Correct 1 ms 2548 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 3 ms 2396 KB Output is correct
37 Correct 1 ms 2392 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 1 ms 2392 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 1 ms 2392 KB Output is correct
43 Correct 1 ms 2648 KB Output is correct
44 Correct 1 ms 2392 KB Output is correct
45 Correct 3 ms 2392 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Execution timed out 4085 ms 15024 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 45 ms 5200 KB Output is correct
3 Correct 47 ms 4176 KB Output is correct
4 Correct 35 ms 5688 KB Output is correct
5 Correct 54 ms 6228 KB Output is correct
6 Correct 35 ms 5712 KB Output is correct
7 Correct 56 ms 6236 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2392 KB Output is correct
20 Correct 2136 ms 11040 KB Output is correct
21 Correct 1172 ms 10452 KB Output is correct
22 Correct 1159 ms 10448 KB Output is correct
23 Correct 1316 ms 11300 KB Output is correct
24 Correct 1307 ms 8880 KB Output is correct
25 Correct 2164 ms 11040 KB Output is correct
26 Correct 2148 ms 11052 KB Output is correct
27 Correct 1 ms 2548 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Correct 1 ms 2392 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 3 ms 2396 KB Output is correct
37 Correct 1 ms 2392 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 1 ms 2392 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 1 ms 2392 KB Output is correct
42 Correct 1 ms 2392 KB Output is correct
43 Correct 1 ms 2648 KB Output is correct
44 Correct 1 ms 2392 KB Output is correct
45 Correct 3 ms 2392 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Execution timed out 4085 ms 15024 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 274 ms 19292 KB Output is correct
6 Correct 1221 ms 19088 KB Output is correct
7 Correct 36 ms 19032 KB Output is correct
8 Correct 163 ms 19032 KB Output is correct
9 Correct 2081 ms 19084 KB Output is correct
10 Correct 36 ms 19032 KB Output is correct
11 Correct 183 ms 19032 KB Output is correct
12 Correct 2029 ms 19084 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2648 KB Output is correct
16 Correct 1 ms 2392 KB Output is correct
17 Correct 1 ms 2392 KB Output is correct
18 Correct 1 ms 2392 KB Output is correct
19 Correct 1 ms 2504 KB Output is correct
20 Correct 1 ms 2392 KB Output is correct
21 Correct 1 ms 2392 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 1 ms 2392 KB Output is correct
24 Correct 1 ms 2392 KB Output is correct
25 Correct 1 ms 2392 KB Output is correct
26 Correct 1 ms 2392 KB Output is correct
27 Correct 1 ms 2552 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2392 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 3 ms 2396 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
33 Correct 1 ms 2392 KB Output is correct
34 Correct 1 ms 2648 KB Output is correct
35 Correct 1 ms 2392 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 1 ms 2392 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 3 ms 2392 KB Output is correct
41 Correct 4 ms 4696 KB Output is correct
42 Correct 2 ms 4696 KB Output is correct
43 Correct 4 ms 4696 KB Output is correct
44 Correct 2 ms 4696 KB Output is correct
45 Correct 4 ms 4696 KB Output is correct
46 Correct 30 ms 4696 KB Output is correct
47 Correct 5 ms 4696 KB Output is correct
48 Correct 22 ms 4700 KB Output is correct
49 Correct 5 ms 4696 KB Output is correct
50 Correct 22 ms 4696 KB Output is correct
51 Execution timed out 4049 ms 19032 KB Time limit exceeded
52 Halted 0 ms 0 KB -