QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#472892#1436. Split in Setswy2025WA 0ms3728kbC++141.0kb2024-07-11 20:07:362024-07-11 20:07:38

Judging History

你现在查看的是最新测评结果

  • [2024-07-11 20:07:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3728kb
  • [2024-07-11 20:07:36]
  • 提交

answer

#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
const int N=1e5+10,M=1e9+7;
int n,now,k,a[N],ans,sce=1;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>k;
	now=n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=k;i++) sce=sce*i%M;
	for(int i=30;~i;i--){
		if(now==k){
			for(int j=1;j<=n;j++) if(a[j]) ans+=a[j];
			break;
		}
		if(k==1){
			int res=(1<<31)-1;
			for(int j=1;j<=n;j++) res&=a[j];
			ans+=res;
			break;
		}
		int cnt=0;
		for(int j=1;j<=n;j++) cnt+=((a[j]>>i)&1);
		if(!cnt) continue;
		if(cnt<k){
			k-=cnt,now-=cnt;
			for(int j=1;j<=n;j++)
				if((a[j]>>i)&1) ans+=a[j],a[j]=0;
		}
		else{
			ans+=(1<<i)*k;
			if(now==cnt)
				for(int j=1;j<=n;j++) a[j]-=1<<i;
			else{
				k--;
				int res=(1ll<<31)-1;
				for(int j=1;j<=n;j++)
					if((a[j]>>i)&1) a[j]-=1<<i;
					else now--,res&=a[j],a[j]=0;
				ans+=res;
			}
		}
//		cout<<i<<" "<<now<<" "<<k<<" "<<ans<<"\n";
	}
	cout<<ans<<" "<<sce;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

input:

3 2
4 7 5

output:

11 2

result:

ok 2 tokens

Test #2:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

4 1
44 47 74 77

output:

8 1

result:

ok 2 tokens

Test #3:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

4 4
44 47 74 77

output:

242 24

result:

ok 2 tokens

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3636kb

input:

1000 975
633065 7087 25267 3940676 618039 1695 2043 728466935 3498 13604984 4 99 119488 151315 12 32 52705062 26815 1902279 33952 480604 390647001 60 1 12566875 7591859 6 119892 7829822 2129 4 11644639 17 33200 5330 338 2 9 6862 3781 148087 57 198 13224999 10493180 1 5755424 216 1757297 210 1002623 ...

output:

35467198614 394187502

result:

wrong answer 1st words differ - expected: '35467198613', found: '35467198614'