답안 #889655

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889655 2023-12-20T04:36:21 Z vjudge1 Council (JOI23_council) C++17
8 / 100
113 ms 39768 KB
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define bc back()
#define ar array
#define vll vector<ll> 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <class _T>
bool chmin(_T &x, const _T &y){
    if(x>y){
        x=y;
        return true;
    }
    return false;
}
template <class _T>
bool chmax(_T &x, const _T &y){
    bool flag=false;
    if (x<y){
        x=y;flag|=true;
    }
    return flag;
}
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
const ll inf=2e18+7;
const ll mod=1e9+7;
const ll N=1e5+7;
const ld eps=1e-9;
ll a[N][23];
ll b[N];
ll mp[N];
void solve(){
	ll i,j,q;
	ll n,m;
	cin>>n>>m;
	ll cnt[m+5],sum=0;
	memset(cnt,0ll,sizeof(cnt));
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cin>>a[i][j];
			if(a[i][j]){
				cnt[j]++;
				b[i]+=(1ll<<(j-1));
			}
		}
		mp[b[i]]++;
	}
	for(j=1;j<=m;j++)if(cnt[j]>=n/2)sum++;
	ll ans[n+5];
	memset(ans,0ll,sizeof(ans));
	if(n<=3000){
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				ll x=sum;
				for(q=1;q<=m;q++){
					ll c=0;
					if(a[i][q])c++;
					if(a[j][q])c++;
					if(cnt[q]>=n/2 && cnt[q]-c<n/2)x--;
				}
				chmax(ans[i],x);
				chmax(ans[j],x);
			}
		}
		for(i=1;i<=n;i++){
			cout<<ans[i]<<endl;
		}
		return;
	}
	for(i=1;i<=n;i++){
		ll f=0,c=0;
		for(j=1;j<=m;j++){
			if(a[i][j] && cnt[j]-1==n/2)f+=(1ll<<(j-1));
			else if(!a[i][j] && cnt[j]==n/2)f+=(1ll<<(j-1));
			if(a[i][j] && cnt[j]-1>=n/2)c++;
			else if(!a[i][j] && cnt[j]>=n/2)c++;
		}
		mp[b[i]]--;
		ll mn=25;
		for(ll mask=0;mask<(1ll<<m);mask++){
			if(mp[mask]==0)continue;
			mn=min(mn,(ll)__builtin_popcount(mask&f));
		}
		mp[b[i]]++;
		cout<<c-mn<<endl;
	}
}
signed main(){
	start();
    ll t=1;
	//cin>>t;
    while(t--) solve();
    return 0;
}
/*
1
6
5 4 3 2 1 0





*/

Compilation message

council.cpp: In function 'void fre(std::string)':
council.cpp:42:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
council.cpp:42:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2428 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 4440 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 8540 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 0 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 0 ms 2396 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 0 ms 2396 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 0 ms 2396 KB Output is correct
48 Correct 0 ms 2396 KB Output is correct
49 Correct 0 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2428 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 4440 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 8540 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 0 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 0 ms 2396 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 0 ms 2396 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 0 ms 2396 KB Output is correct
48 Correct 0 ms 2396 KB Output is correct
49 Correct 0 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 113 ms 4560 KB Output is correct
52 Correct 94 ms 2512 KB Output is correct
53 Correct 102 ms 8800 KB Output is correct
54 Incorrect 113 ms 8796 KB Output isn't correct
55 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Runtime error 25 ms 39768 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Runtime error 25 ms 39768 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Runtime error 25 ms 39768 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Runtime error 25 ms 39768 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2428 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 2 ms 4440 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 1 ms 8540 KB Output is correct
12 Correct 2 ms 8540 KB Output is correct
13 Correct 0 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 0 ms 2396 KB Output is correct
23 Correct 0 ms 2396 KB Output is correct
24 Correct 0 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 0 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 1 ms 2392 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 0 ms 2396 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 0 ms 2396 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 0 ms 2396 KB Output is correct
48 Correct 0 ms 2396 KB Output is correct
49 Correct 0 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 113 ms 4560 KB Output is correct
52 Correct 94 ms 2512 KB Output is correct
53 Correct 102 ms 8800 KB Output is correct
54 Incorrect 113 ms 8796 KB Output isn't correct
55 Halted 0 ms 0 KB -