QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#470641#5024. 【模板】双端队列b6e00 0ms0kbC++141.1kb2024-07-10 15:36:562024-07-10 15:36:57

Judging History

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

  • [2024-07-10 15:36:57]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-07-10 15:36:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int S1=1<<20;
char buf1[S1],*l1,*r1;
#define getchar() ((l1==r1&&(r1=(l1=buf1)+fread(buf1,1,S1,stdin)),l1!=r1)?*l1++:EOF)
template<typename T=int>inline T read()
{
	T x=0;
	char c=getchar();
	while(c<'0'||c>'9')
		c=getchar();
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x;
}
constexpr int MN=50005;
int n,a[MN];
inline bool check(int l,int r)
{
	for(;l<=r&&a[l]==a[r];l++,r--);
	for(;l<=r;l+=2)
		if(a[l]!=a[l+1])
			return 0;
	return 1;
}
inline void work()
{
	n=read();
	int s=0;
	for(int i=1;i<=n;i++)
		s^=(a[i]=read());
	if(!s)
	{
		puts("Draw");
		return;
	}
	if((~n&1)||n==1)
	{
		puts("First");
		return;
	}
	for(int i=30;~i;i--)
		if((s>>i)&1)
		{
			s=0;
			for(int j=1;j<=n;j++)
				s+=(a[j]=(a[j]>>i)&1);
			break;
		}
	if(s%4==1&&((a[1]&&check(2,n))||(a[n]&&check(1,n-1))))
		puts("First");
	else
		puts("Second");
}
int main()
{
	freopen("million.in","r",stdin);
	freopen("million.out","w",stdout);
	int T=read();
	while(T--)
		work();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Dangerous Syscalls

Test #1:

score: 0
Dangerous Syscalls

input:

40
15
1042186166 1065050038 1052442342 117744385 1044381358 996146407 947617159 1031691934 27328777 130294601 1065311743 1065082111 12845136 941620871 1042177446
15
1068465534 15766217 69219008 95461385 1048542590 1051709438 1048575351 1072652151 978275647 1044381687 999247358 1062194999 1054829887 ...

output:


result:


Subtask #2:

score: 0
Dangerous Syscalls

Test #2:

score: 0
Dangerous Syscalls

input:

40
987
1073733087 9437225 570431533 1031755263 1031755251 579873284 571521061 536872960 546353705 43000364 535780827 1065313790 536834043 41953824 503270871 1040175099 8426021 537960961 1054732 545292837 34648585 34603052 546314244 537965060 9439748 41953292 43037189 9447949 536864767 1073698294 503...

output:


result:


Subtask #3:

score: 0
Dangerous Syscalls

Test #4:

score: 0
Dangerous Syscalls

input:

40
49999
30704571 23631198 10459697 452884 909025 3745220 5633170 29257098 24428644 21991837 21100897 21249665 18667093 13809790 21220831 32750672 29531337 31709216 17139349 4444339 787544 14509794 3855820 201034 13281440 26541636 31476242 10318360 20485824 26793325 8264891 22349828 20554718 7556006...

output:


result:


Subtask #4:

score: 0
Dangerous Syscalls

Test #6:

score: 0
Dangerous Syscalls

input:

40
49035
1073176430 531291499 1005508607 675350672 368768 867368831 139504132 1321089 134482448 464248170 1068169195 68946580 469491567 738764816 742459920 535197167 531887598 672172545 609558673 608209040 335282031 532674543 72878741 610117777 138447508 398155759 71608464 672172165 402325355 609845...

output:


result: