답안 #889832

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889832 2023-12-20T07:52:49 Z vjudge1 Council (JOI23_council) C++17
25 / 100
4000 ms 8540 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++){
				int sum = 0;
				for(int j = 0; j < m; j++){
					if(cnt[j] - (mask >> j & 1) - a[i][j] >= n / 2) sum++;
				}
				if(mp[mask] <= 0) continue;
				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 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1095 ms 8540 KB Output is correct
6 Execution timed out 4058 ms 8540 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1095 ms 8540 KB Output is correct
6 Execution timed out 4058 ms 8540 KB Time limit exceeded
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 47 ms 1524 KB Output is correct
3 Correct 43 ms 1616 KB Output is correct
4 Correct 32 ms 1108 KB Output is correct
5 Correct 47 ms 1616 KB Output is correct
6 Correct 32 ms 1112 KB Output is correct
7 Correct 48 ms 1616 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 47 ms 1524 KB Output is correct
3 Correct 43 ms 1616 KB Output is correct
4 Correct 32 ms 1108 KB Output is correct
5 Correct 47 ms 1616 KB Output is correct
6 Correct 32 ms 1112 KB Output is correct
7 Correct 48 ms 1616 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 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 0 ms 348 KB Output is correct
20 Correct 3690 ms 4224 KB Output is correct
21 Correct 1700 ms 3628 KB Output is correct
22 Correct 1718 ms 3872 KB Output is correct
23 Correct 3329 ms 4472 KB Output is correct
24 Correct 3306 ms 4236 KB Output is correct
25 Correct 3469 ms 4036 KB Output is correct
26 Correct 3444 ms 4064 KB Output is correct
27 Correct 0 ms 344 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 1 ms 600 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 4 ms 348 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 0 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 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 47 ms 1524 KB Output is correct
3 Correct 43 ms 1616 KB Output is correct
4 Correct 32 ms 1108 KB Output is correct
5 Correct 47 ms 1616 KB Output is correct
6 Correct 32 ms 1112 KB Output is correct
7 Correct 48 ms 1616 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 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 0 ms 348 KB Output is correct
20 Correct 3690 ms 4224 KB Output is correct
21 Correct 1700 ms 3628 KB Output is correct
22 Correct 1718 ms 3872 KB Output is correct
23 Correct 3329 ms 4472 KB Output is correct
24 Correct 3306 ms 4236 KB Output is correct
25 Correct 3469 ms 4036 KB Output is correct
26 Correct 3444 ms 4064 KB Output is correct
27 Correct 0 ms 344 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 1 ms 600 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 4 ms 348 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 0 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 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 4 ms 344 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Execution timed out 4083 ms 4936 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 47 ms 1524 KB Output is correct
3 Correct 43 ms 1616 KB Output is correct
4 Correct 32 ms 1108 KB Output is correct
5 Correct 47 ms 1616 KB Output is correct
6 Correct 32 ms 1112 KB Output is correct
7 Correct 48 ms 1616 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 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 0 ms 348 KB Output is correct
20 Correct 3690 ms 4224 KB Output is correct
21 Correct 1700 ms 3628 KB Output is correct
22 Correct 1718 ms 3872 KB Output is correct
23 Correct 3329 ms 4472 KB Output is correct
24 Correct 3306 ms 4236 KB Output is correct
25 Correct 3469 ms 4036 KB Output is correct
26 Correct 3444 ms 4064 KB Output is correct
27 Correct 0 ms 344 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 1 ms 600 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 4 ms 348 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 0 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 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 4 ms 344 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Execution timed out 4083 ms 4936 KB Time limit exceeded
48 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1095 ms 8540 KB Output is correct
6 Execution timed out 4058 ms 8540 KB Time limit exceeded
7 Halted 0 ms 0 KB -