답안 #889774

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889774 2023-12-20T07:05:54 Z vjudge1 Council (JOI23_council) C++17
41 / 100
4000 ms 8716 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ordered_multiset tree<type1, null_type, less_equal<type1>, rb_tree_tag, tree_order_statistics_node_update>;

using namespace std;
using namespace __gnu_pbds;

const int mod = 1e9+7;
const double PI = acos(-1.0);
const double epsilon = 1e-6;

void solve(){
	int n,m;
	cin >> n >> m;
	bool a[n][m];
	int cnt[m]{};
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
			cnt[j] += a[i][j];
		}
	}
	if(0){
		for(int i = 0; i < n; i++){
			int mx = 0;
			for(int j = 0; j < n; j++){
				if(i == j) continue;
				int sum = 0;
				for(int k = 0; k < m; k++){
					if(cnt[k] - a[i][k] - a[j][k] >= n / 2) sum++;
				}
				mx = max(mx,sum);
			}
			cout << mx << '\n';
		}
	}else{
		vector<int> mp(1 << m);
		for(int i = 0; i < n; i++){
			int sum = 0;
			for(int j = 0; j < m; j++){
				sum += (a[i][j] << j);
			}
			mp[sum]++;
		}
		for(int i = 0; i < n; i++){
			int ans = 0;
			int ind = 0;
			for(int j = 0; j < m; j++){
				ind += (a[i][j] << j);
			}
			mp[ind]--;
			for(int mask = 0; mask < (1 << m); mask++){
				if(mp[mask] <= 0) continue;
				int sum = 0;
				for(int j = 0; j < m; j++){
					if(cnt[j] - (mask >> j & 1) - a[i][j] >= n / 2) sum++;
				}
				ans = max(ans,sum);
			}
			mp[ind]++;
			cout << ans << '\n';
		}
	}
}

main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int tt = 1;
    //cin >> tt;
    while (tt--) {
        solve();
    }
}

Compilation message

council.cpp:75:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   75 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 39 ms 8540 KB Output is correct
6 Correct 293 ms 8540 KB Output is correct
7 Correct 7 ms 8540 KB Output is correct
8 Correct 21 ms 8540 KB Output is correct
9 Correct 306 ms 8536 KB Output is correct
10 Correct 7 ms 8540 KB Output is correct
11 Correct 41 ms 8664 KB Output is correct
12 Correct 294 ms 8536 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 5 ms 1372 KB Output is correct
47 Correct 1 ms 1384 KB Output is correct
48 Correct 6 ms 1372 KB Output is correct
49 Correct 1 ms 1368 KB Output is correct
50 Correct 3 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 39 ms 8540 KB Output is correct
6 Correct 293 ms 8540 KB Output is correct
7 Correct 7 ms 8540 KB Output is correct
8 Correct 21 ms 8540 KB Output is correct
9 Correct 306 ms 8536 KB Output is correct
10 Correct 7 ms 8540 KB Output is correct
11 Correct 41 ms 8664 KB Output is correct
12 Correct 294 ms 8536 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 5 ms 1372 KB Output is correct
47 Correct 1 ms 1384 KB Output is correct
48 Correct 6 ms 1372 KB Output is correct
49 Correct 1 ms 1368 KB Output is correct
50 Correct 3 ms 1372 KB Output is correct
51 Correct 3034 ms 8716 KB Output is correct
52 Correct 2961 ms 8712 KB Output is correct
53 Correct 3178 ms 8712 KB Output is correct
54 Correct 3192 ms 8712 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 557 ms 1516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 48 ms 1540 KB Output is correct
3 Correct 43 ms 1396 KB Output is correct
4 Correct 31 ms 1112 KB Output is correct
5 Correct 49 ms 1620 KB Output is correct
6 Correct 32 ms 1108 KB Output is correct
7 Correct 48 ms 1628 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 412 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 48 ms 1540 KB Output is correct
3 Correct 43 ms 1396 KB Output is correct
4 Correct 31 ms 1112 KB Output is correct
5 Correct 49 ms 1620 KB Output is correct
6 Correct 32 ms 1108 KB Output is correct
7 Correct 48 ms 1628 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 412 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1190 ms 4356 KB Output is correct
21 Correct 649 ms 3604 KB Output is correct
22 Correct 733 ms 3668 KB Output is correct
23 Correct 483 ms 4216 KB Output is correct
24 Correct 451 ms 3984 KB Output is correct
25 Correct 3466 ms 3816 KB Output is correct
26 Correct 3436 ms 4124 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 2 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 48 ms 1540 KB Output is correct
3 Correct 43 ms 1396 KB Output is correct
4 Correct 31 ms 1112 KB Output is correct
5 Correct 49 ms 1620 KB Output is correct
6 Correct 32 ms 1108 KB Output is correct
7 Correct 48 ms 1628 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 412 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1190 ms 4356 KB Output is correct
21 Correct 649 ms 3604 KB Output is correct
22 Correct 733 ms 3668 KB Output is correct
23 Correct 483 ms 4216 KB Output is correct
24 Correct 451 ms 3984 KB Output is correct
25 Correct 3466 ms 3816 KB Output is correct
26 Correct 3436 ms 4124 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 2 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Execution timed out 4038 ms 5236 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 48 ms 1540 KB Output is correct
3 Correct 43 ms 1396 KB Output is correct
4 Correct 31 ms 1112 KB Output is correct
5 Correct 49 ms 1620 KB Output is correct
6 Correct 32 ms 1108 KB Output is correct
7 Correct 48 ms 1628 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 412 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1190 ms 4356 KB Output is correct
21 Correct 649 ms 3604 KB Output is correct
22 Correct 733 ms 3668 KB Output is correct
23 Correct 483 ms 4216 KB Output is correct
24 Correct 451 ms 3984 KB Output is correct
25 Correct 3466 ms 3816 KB Output is correct
26 Correct 3436 ms 4124 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 2 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Execution timed out 4038 ms 5236 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 39 ms 8540 KB Output is correct
6 Correct 293 ms 8540 KB Output is correct
7 Correct 7 ms 8540 KB Output is correct
8 Correct 21 ms 8540 KB Output is correct
9 Correct 306 ms 8536 KB Output is correct
10 Correct 7 ms 8540 KB Output is correct
11 Correct 41 ms 8664 KB Output is correct
12 Correct 294 ms 8536 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 5 ms 1372 KB Output is correct
47 Correct 1 ms 1384 KB Output is correct
48 Correct 6 ms 1372 KB Output is correct
49 Correct 1 ms 1368 KB Output is correct
50 Correct 3 ms 1372 KB Output is correct
51 Correct 3034 ms 8716 KB Output is correct
52 Correct 2961 ms 8712 KB Output is correct
53 Correct 3178 ms 8712 KB Output is correct
54 Correct 3192 ms 8712 KB Output is correct
55 Correct 1 ms 348 KB Output is correct
56 Correct 557 ms 1516 KB Output is correct
57 Correct 0 ms 344 KB Output is correct
58 Correct 48 ms 1540 KB Output is correct
59 Correct 43 ms 1396 KB Output is correct
60 Correct 31 ms 1112 KB Output is correct
61 Correct 49 ms 1620 KB Output is correct
62 Correct 32 ms 1108 KB Output is correct
63 Correct 48 ms 1628 KB Output is correct
64 Correct 0 ms 344 KB Output is correct
65 Correct 1 ms 344 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 1 ms 412 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 0 ms 344 KB Output is correct
70 Correct 0 ms 344 KB Output is correct
71 Correct 1 ms 344 KB Output is correct
72 Correct 1 ms 348 KB Output is correct
73 Correct 1 ms 348 KB Output is correct
74 Correct 0 ms 348 KB Output is correct
75 Correct 1 ms 348 KB Output is correct
76 Correct 1190 ms 4356 KB Output is correct
77 Correct 649 ms 3604 KB Output is correct
78 Correct 733 ms 3668 KB Output is correct
79 Correct 483 ms 4216 KB Output is correct
80 Correct 451 ms 3984 KB Output is correct
81 Correct 3466 ms 3816 KB Output is correct
82 Correct 3436 ms 4124 KB Output is correct
83 Correct 0 ms 348 KB Output is correct
84 Correct 0 ms 348 KB Output is correct
85 Correct 0 ms 348 KB Output is correct
86 Correct 0 ms 348 KB Output is correct
87 Correct 0 ms 348 KB Output is correct
88 Correct 0 ms 348 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 0 ms 348 KB Output is correct
91 Correct 0 ms 348 KB Output is correct
92 Correct 2 ms 344 KB Output is correct
93 Correct 0 ms 348 KB Output is correct
94 Correct 0 ms 348 KB Output is correct
95 Correct 0 ms 348 KB Output is correct
96 Correct 1 ms 348 KB Output is correct
97 Correct 0 ms 348 KB Output is correct
98 Correct 0 ms 348 KB Output is correct
99 Correct 1 ms 344 KB Output is correct
100 Correct 0 ms 348 KB Output is correct
101 Correct 1 ms 348 KB Output is correct
102 Correct 0 ms 348 KB Output is correct
103 Execution timed out 4038 ms 5236 KB Time limit exceeded
104 Halted 0 ms 0 KB -