Submission #60056895


Source Code Expand

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+10;
int n,a[N],res,cnt[N];
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1,j=1;2*i<=n;j=max(j,++i))
	{
		if(a[2*i]!=a[2*i-1])
		{
			continue;
		}
		while(2*j<=n&&a[2*j]==a[2*j-1]&&!cnt[a[2*j]])
		{
			cnt[a[2*j]]++;
			j++;
		}
		res=max(res,j-i);
		cnt[a[2*i]]--;
	}
	
	for(int i=1,j=1;2*i+1<=n;j=max(j,++i))
	{
		if(a[2*i]!=a[2*i+1])
		{
			continue;
		}
		while(2*j+1<=n&&a[2*j]==a[2*j+1]&&!cnt[a[2*j]])
		{
			cnt[a[2*j]]++;
			j++;
		}
		res=max(res,j-i);
		cnt[a[2*i]]--;
	}
	cout<<2*res<<flush;
	return 0;
}

Submission Info

Submission Time
Task D - 1122 Substring
User syp11
Language C++ 20 (gcc 12.2)
Score 425
Code Size 730 Byte
Status AC
Exec Time 12 ms
Memory 6720 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 3
AC × 39
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt
Case Name Status Exec Time Memory
example_00.txt AC 1 ms 3420 KiB
example_01.txt AC 1 ms 3480 KiB
example_02.txt AC 1 ms 3540 KiB
hand_00.txt AC 11 ms 6536 KiB
hand_01.txt AC 12 ms 5100 KiB
hand_02.txt AC 11 ms 6584 KiB
hand_03.txt AC 12 ms 6720 KiB
hand_04.txt AC 9 ms 5060 KiB
hand_05.txt AC 1 ms 3532 KiB
random_00.txt AC 12 ms 5076 KiB
random_01.txt AC 11 ms 5008 KiB
random_02.txt AC 11 ms 5184 KiB
random_03.txt AC 10 ms 5328 KiB
random_04.txt AC 11 ms 6512 KiB
random_05.txt AC 11 ms 6712 KiB
random_06.txt AC 11 ms 6512 KiB
random_07.txt AC 11 ms 6580 KiB
random_08.txt AC 11 ms 6468 KiB
random_09.txt AC 12 ms 6464 KiB
random_10.txt AC 10 ms 4976 KiB
random_11.txt AC 11 ms 4952 KiB
random_12.txt AC 11 ms 5048 KiB
random_13.txt AC 11 ms 5420 KiB
random_14.txt AC 11 ms 6512 KiB
random_15.txt AC 12 ms 6456 KiB
random_16.txt AC 12 ms 6584 KiB
random_17.txt AC 11 ms 6656 KiB
random_18.txt AC 11 ms 6612 KiB
random_19.txt AC 12 ms 6604 KiB
random_20.txt AC 11 ms 6528 KiB
random_21.txt AC 11 ms 6584 KiB
random_22.txt AC 12 ms 6584 KiB
random_23.txt AC 11 ms 6524 KiB
random_24.txt AC 11 ms 6660 KiB
random_25.txt AC 11 ms 6536 KiB
random_26.txt AC 12 ms 6508 KiB
random_27.txt AC 11 ms 6712 KiB
random_28.txt AC 11 ms 4980 KiB
random_29.txt AC 10 ms 5112 KiB