답안 #889833

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889833 2023-12-20T07:53:34 Z vjudge1 Tourism (JOI23_tourism) C++17
0 / 100
1 ms 604 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

tourism.cpp:75:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   75 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -