QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751883#9745. 递增序列doyoWA 31ms5712kbC++201.2kb2024-11-15 21:10:362024-11-15 21:10:39

Judging History

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

  • [2024-11-15 21:10:39]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:5712kb
  • [2024-11-15 21:10:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,j,k) for(int i=j;i<=k;++i)
#define For(i,j,k) for(int i=j;i>=k;--i)
const int N = 2e5 + 111;
int a[N]; 
int son[N*60][2];
int d[65];
void sol(){
	int n,m;
	cin>>n>>m;
	FOR(i,1,n) cin>>a[i];
	int up = 60;
	
	FOR(i,0,up) d[i]=-1;
	
	int rt = 0;
	int cnt = 0;
	For(i,n,1){
		int now = rt;
		For(k,60,0){
			int val = 0;
			if(a[i]&(1ll<<k)) val = 1;
			if(son[now][val^1]){
				if(d[k]==-1){
					d[k] = val; 
				}
				else{
					if(d[k]!=val){
						return cout<<0<<'\n',void();
					}
				}
			}
			if(!son[now][val]) son[now][val] = ++cnt;
			now = son[now][val];
		}
	}
	int ans = 0;
	For(k,up,0){
		if(m&(1ll<<k)){
			if(d[k]==-1){
				int ccnt = 0;
				For(j,k-1,0) if(d[j]==-1) ++ccnt;
				ans += (1ll<<ccnt);
			}
			if(d[k]==0){
				int ccnt = 0;
				For(j,k-1,0) if(d[j]==-1) ++ccnt;
				ans += (1ll<<ccnt);
				break;
			}
		}
		else{
			if(d[k]==1){
				break;
			}
		}
	}
	FOR(i,0,cnt) son[i][0] = son[i][1] = 0;
	cout<<ans<<'\n';
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		sol();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5712kb

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

score: -100
Wrong Answer
time: 31ms
memory: 5680kb

input:

36156
2 732025001343805266
563399128172323734 55283226774627822
7 388099190813067712
564150557919527813 457487771983557281 332055400678110195 760833651510929158 785768483273197875 690506113272551236 463276585748519124
2 798714574862593347
426890163990834364 434764725667883272
1 414708220571820990
42...

output:

288230376151711744
0
0
32
10
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
0...

result:

wrong answer 3rd lines differ - expected: '432345564227567616', found: '0'