QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#673715#7932. AND-OR closurerotcar07WA 13ms9680kbC++23785b2024-10-25 09:19:532024-10-25 09:19:54

Judging History

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

  • [2024-10-25 09:19:54]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:9680kb
  • [2024-10-25 09:19:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;ll zhuzhu[40];
constexpr int B=1<<20;
bool dp[B];
int dq[B];
int msk[B];
int main(){
	cin>>n;ll ans=(1ll<<40)-1;
	for(int i=1;i<=n;i++){
		ll x;cin>>x;
		for(int j=0;j<40;j++)if(x>>j&1){
			if(!zhuzhu[j]) zhuzhu[j]=x;
			else zhuzhu[j]&=x;
		}
		ans&=x;
	}
	dq[0]=ans;ans=0;
	for(int i=0;i<40;i++) dq[zhuzhu[i]&B-1]=1,dp[zhuzhu[i]>>20]=1;
	for(int i=0;i<B;i++)if(dq[i])
		for(int j=0;j<40;j++) dq[i|(zhuzhu[j]&B-1)]=1;
	for(int i=0;i<20;i++)
	for(int j=B-1;j>=0;j--)if(!(j>>i&1)) dq[j]+=dq[j^(1<<i)];
	for(int i=0;i<B;i++)if(dp[i]){
		for(int j=0;j<40;j++) dp[i|(zhuzhu[j]>>20)]=1;
		if(i){int x=i&-i;msk[i]=msk[i^x]|(zhuzhu[__lg(x)]&B-1);}
		ans+=dq[msk[i]];
	}
	cout<<ans<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 9ms
memory: 9680kb

input:

4
0 1 3 5

output:

5

result:

ok 1 number(s): "5"

Test #2:

score: 0
Accepted
time: 10ms
memory: 8404kb

input:

5
0 1 2 3 4

output:

8

result:

ok 1 number(s): "8"

Test #3:

score: -100
Wrong Answer
time: 13ms
memory: 8516kb

input:

49
1097363587067 1096810445814 275012137504 1096739142630 1096809921522 1087071335264 829364908576 949625500192 1087142638448 1096200190829 1097292808175 1095750860656 1087144145776 1097346808827 1095734082416 1096755396578 829230678048 1095663303524 1087072842592 1096216444777 949623992864 10962714...

output:

755

result:

wrong answer 1st numbers differ - expected: '52', found: '755'