답안 #1077452

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077452 2024-08-27T07:21:23 Z vjudge1 Council (JOI23_council) C++17
6 / 100
845 ms 56280 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define ppb pop_back
#define ep insert
#define endl '\n'
#define elif else if
#define pow pwr
#define sqrt sqrtt
#define int long long
#define ll long long
typedef unsigned long long ull;
using namespace std;
const int N=3e5+5,M=2e6;
int a[N],dp1[M],f[20],n,m;
pair<int,int> dp2[M];
pair<int,int> merge(pair<int,int> x,pair<int,int> y){
	vector<int> v;
	v.pb(x.F);v.pb(x.S);v.pb(y.F);v.pb(y.S);
	sort(v.begin(),v.end());
	return {v[0],v[1]};
}
int32_t main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	for (int i=0;i<M;i++) dp2[i]={INT_MAX,INT_MAX};
	cin>>n>>m;
	for (int i=1;i<=n;i++){
		for (int j=0;j<m;j++){
			bool x;cin>>x;
			if (x) a[i]|=(1<<j),f[j]++;
		}
		dp1[a[i]]++;
		dp2[a[i]]=merge({__builtin_popcount(a[i]),INT_MAX},dp2[a[i]]);
	}	
	//for (int i=0;i<4;i++) cout<<dp2[i].F<<' '<<dp2[i].S<<"	";cout<<endl;
	for (int j=0;j<m;j++){
		for (int i=0;i<M;i++){
			if (i&(1<<j)) dp1[i]+=dp1[i-(1<<j)];
			else dp2[i]=merge(dp2[i],dp2[i+(1<<j)]);
		}
	}
	//for (int i=0;i<4;i++) cout<<dp2[i].F<<' '<<dp2[i].S<<"	";cout<<endl;
	for (int i=1;i<=n;i++){
		for (int j=0;j<m;j++){
			if (a[i]&(1<<j)) f[j]--;
		}
		int mask=0;
		for (int j=0;j<m;j++){
			if (f[j]!=n/2) mask|=(1<<j);
		}
		if (dp1[mask]>1 || (dp1[mask]==1 && (mask|a[i])!=mask)){
			int x=0;
			for (int j=0;j<m;j++) if (f[j]>=n/2) x++;
			cout<<x<<endl;
			for (int j=0;j<m;j++){
			if (a[i]&(1<<j)) f[j]++;
		}
			continue;
		}
		int x=0;
		if (dp2[mask].F!=__builtin_popcount(a[i]) || (mask|a[i])!=a[i]) x=dp2[mask].F;
		else x=dp2[mask].S;
		int y=0;
		for (int j=0;j<m;j++) if (f[j]>=n/2) y++;
		cout<<y-(x-__builtin_popcount(mask))<<endl;
		for (int j=0;j<m;j++){
			if (a[i]&(1<<j)) f[j]++;
		}
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 203 ms 47328 KB Output is correct
2 Incorrect 768 ms 47188 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 203 ms 47328 KB Output is correct
2 Incorrect 768 ms 47188 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 148 ms 47184 KB Output is correct
2 Correct 216 ms 51536 KB Output is correct
3 Correct 202 ms 48976 KB Output is correct
4 Correct 126 ms 50736 KB Output is correct
5 Correct 213 ms 51280 KB Output is correct
6 Correct 131 ms 50916 KB Output is correct
7 Correct 213 ms 51276 KB Output is correct
8 Correct 86 ms 47184 KB Output is correct
9 Correct 82 ms 47184 KB Output is correct
10 Correct 145 ms 47316 KB Output is correct
11 Correct 152 ms 47188 KB Output is correct
12 Correct 142 ms 47340 KB Output is correct
13 Correct 85 ms 47276 KB Output is correct
14 Correct 174 ms 47188 KB Output is correct
15 Correct 154 ms 47316 KB Output is correct
16 Correct 141 ms 47180 KB Output is correct
17 Correct 142 ms 47444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 148 ms 47184 KB Output is correct
2 Correct 216 ms 51536 KB Output is correct
3 Correct 202 ms 48976 KB Output is correct
4 Correct 126 ms 50736 KB Output is correct
5 Correct 213 ms 51280 KB Output is correct
6 Correct 131 ms 50916 KB Output is correct
7 Correct 213 ms 51276 KB Output is correct
8 Correct 86 ms 47184 KB Output is correct
9 Correct 82 ms 47184 KB Output is correct
10 Correct 145 ms 47316 KB Output is correct
11 Correct 152 ms 47188 KB Output is correct
12 Correct 142 ms 47340 KB Output is correct
13 Correct 85 ms 47276 KB Output is correct
14 Correct 174 ms 47188 KB Output is correct
15 Correct 154 ms 47316 KB Output is correct
16 Correct 141 ms 47180 KB Output is correct
17 Correct 142 ms 47444 KB Output is correct
18 Correct 205 ms 47300 KB Output is correct
19 Correct 261 ms 47184 KB Output is correct
20 Correct 843 ms 56144 KB Output is correct
21 Correct 744 ms 55544 KB Output is correct
22 Correct 748 ms 55572 KB Output is correct
23 Correct 798 ms 56280 KB Output is correct
24 Correct 780 ms 53840 KB Output is correct
25 Correct 845 ms 56144 KB Output is correct
26 Correct 838 ms 56008 KB Output is correct
27 Incorrect 624 ms 47408 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 148 ms 47184 KB Output is correct
2 Correct 216 ms 51536 KB Output is correct
3 Correct 202 ms 48976 KB Output is correct
4 Correct 126 ms 50736 KB Output is correct
5 Correct 213 ms 51280 KB Output is correct
6 Correct 131 ms 50916 KB Output is correct
7 Correct 213 ms 51276 KB Output is correct
8 Correct 86 ms 47184 KB Output is correct
9 Correct 82 ms 47184 KB Output is correct
10 Correct 145 ms 47316 KB Output is correct
11 Correct 152 ms 47188 KB Output is correct
12 Correct 142 ms 47340 KB Output is correct
13 Correct 85 ms 47276 KB Output is correct
14 Correct 174 ms 47188 KB Output is correct
15 Correct 154 ms 47316 KB Output is correct
16 Correct 141 ms 47180 KB Output is correct
17 Correct 142 ms 47444 KB Output is correct
18 Correct 205 ms 47300 KB Output is correct
19 Correct 261 ms 47184 KB Output is correct
20 Correct 843 ms 56144 KB Output is correct
21 Correct 744 ms 55544 KB Output is correct
22 Correct 748 ms 55572 KB Output is correct
23 Correct 798 ms 56280 KB Output is correct
24 Correct 780 ms 53840 KB Output is correct
25 Correct 845 ms 56144 KB Output is correct
26 Correct 838 ms 56008 KB Output is correct
27 Incorrect 624 ms 47408 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 148 ms 47184 KB Output is correct
2 Correct 216 ms 51536 KB Output is correct
3 Correct 202 ms 48976 KB Output is correct
4 Correct 126 ms 50736 KB Output is correct
5 Correct 213 ms 51280 KB Output is correct
6 Correct 131 ms 50916 KB Output is correct
7 Correct 213 ms 51276 KB Output is correct
8 Correct 86 ms 47184 KB Output is correct
9 Correct 82 ms 47184 KB Output is correct
10 Correct 145 ms 47316 KB Output is correct
11 Correct 152 ms 47188 KB Output is correct
12 Correct 142 ms 47340 KB Output is correct
13 Correct 85 ms 47276 KB Output is correct
14 Correct 174 ms 47188 KB Output is correct
15 Correct 154 ms 47316 KB Output is correct
16 Correct 141 ms 47180 KB Output is correct
17 Correct 142 ms 47444 KB Output is correct
18 Correct 205 ms 47300 KB Output is correct
19 Correct 261 ms 47184 KB Output is correct
20 Correct 843 ms 56144 KB Output is correct
21 Correct 744 ms 55544 KB Output is correct
22 Correct 748 ms 55572 KB Output is correct
23 Correct 798 ms 56280 KB Output is correct
24 Correct 780 ms 53840 KB Output is correct
25 Correct 845 ms 56144 KB Output is correct
26 Correct 838 ms 56008 KB Output is correct
27 Incorrect 624 ms 47408 KB Output isn't correct
28 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 203 ms 47328 KB Output is correct
2 Incorrect 768 ms 47188 KB Output isn't correct
3 Halted 0 ms 0 KB -