QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#763424#9745. 递增序列rzyyyy#WA 30ms3680kbC++201.3kb2024-11-19 20:12:272024-11-19 20:12:28

Judging History

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

  • [2024-11-19 20:12:28]
  • 评测
  • 测评结果:WA
  • 用时:30ms
  • 内存:3680kb
  • [2024-11-19 20:12:27]
  • 提交

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=4;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: 3680kb

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

score: -100
Wrong Answer
time: 30ms
memory: 3660kb

input:

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

output:

19
0
580
18559
593870
0
19003824
0
0
0
608122339
0
0
19459914828
622717274494
19926952783781
637662489080972
0
20405199650591083
0
652966388818914648
2448180368495717118
0
0
0
0
4554795497024741307
-1820496684884691113
-2915661695181460779
-1067453877258986864
0
2734964075131523578
0
-47148699643390...

result:

wrong answer 1st lines differ - expected: '288230376151711744', found: '19'