QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#763428#9745. 递增序列rzyyyy#WA 31ms3672kbC++201.3kb2024-11-19 20:13:312024-11-19 20:13:31

Judging History

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

  • [2024-11-19 20:13:31]
  • 评测
  • 测评结果:WA
  • 用时:31ms
  • 内存:3672kb
  • [2024-11-19 20:13:31]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5;
int T,n,p[60];
ll m,a[N],f[2],g[2];
bool flag;
void check(int x,int y)
{
	if(p[x]==-1||p[x]==y) p[x]=y;
	else flag=false;
	return;
}
void calc(ll x,ll y)
{
	for(int i=59;i>=0;i--)
	{
		if(((x>>i)&1)!=((y>>i)&1))
		{
			if((x>>i)&1) check(i,1);
			else check(i,0);
			return;
		}
	}
	return;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>T;
	while(T--)
	{
		for(int i=59;i>=0;i--) p[i]=-1;
		cin>>n>>m;flag=true;
		for(int i=1;i<=n;i++) cin>>a[i];
		for(int i=1;i<n;i++) calc(a[i],a[i+1]);
		if(!flag) {cout<<"0\n";continue;}
		f[1]=1;
		for(int i=59;i>=0;i--)
		{
			if((1ll<<i)>m)
			{
				if(p[i]==1) {f[0]=f[1]=0;break;}
				else continue;
			}
			if((m>>i)&1)
			{
				if(p[i]==-1)
				{
					g[0]=f[0]*2+f[1];
					g[1]=f[1];
				}
				if(p[i]==1)
				{
					g[0]=f[0];
					g[1]=f[1];
				}
				if(p[i]==0)
				{
					g[0]=f[0]+f[1];
					g[1]=0;
				}
			}
			else
			{
				if(p[i]==-1)
				{
					g[0]=f[0]*2;
					g[1]=f[1];
				}
				if(p[i]==1)
				{
					g[0]=f[0];
					g[1]=0;
				}
				if(p[i]==0)
				{
					g[0]=f[0];
					g[1]=f[1];
				}
			}
			f[0]=g[0];
			f[1]=g[1];
		}
		cout<<f[0]+f[1]<<"\n";
	}
	return 0;
}
/*
1
4 17
3 2 5 16
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

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

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
432345564227567616
414708220571820991
-1589444817021323314
0
7495939434859275088
0
0
0
-341912315239003453
0
0
0
114457959388827198
4431542033332568064
0
0
91540211282631659
0
-6222825795871186216
-5764607523034234880
0
0
0
0
432345564227567616
65333152962117911
7670875400250956...

result:

wrong answer 5th lines differ - expected: '716398192192370638', found: '-1589444817021323314'