Submission #60959261


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
const int N = 3005;
int n,a[N],f[N][N],ans;
int main()
{
// freopen("in.in","r",stdin);
// freopen("out.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) f[i][j]=1; ans=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<i;j++)
{
if(a[i]==a[j])
{
f[i][i-j]=max(f[i][i-j],f[j][i-j]+1);
ans=max(ans,f[i][i-j]);
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
const int N = 3005;
int n,a[N],f[N][N],ans;
int main()
{
	// freopen("in.in","r",stdin);
	// freopen("out.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) f[i][j]=1; ans=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<i;j++)
		{
			if(a[i]==a[j])
			{
				f[i][i-j]=max(f[i][i-j],f[j][i-j]+1);
				ans=max(ans,f[i][i-j]);
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Submission Info

Submission Time
Task C - Illuminate Buildings
User ppllxx
Language C++ 20 (gcc 12.2)
Score 350
Code Size 506 Byte
Status AC
Exec Time 33 ms
Memory 38996 KB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:11:9: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
   11 |         for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) f[i][j]=1; ans=1;
      |         ^~~
Main.cpp:11:64: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
   11 |         for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) f[i][j]=1; ans=1;
      |                                                                ^~~
Main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
Main.cpp:10:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         for(int i=1;i<=n;i++) scanf("%d",&a[i]);
      |                               ~~~~~^~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 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, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 25 ms 38920 KB
random_02.txt AC 10 ms 20720 KB
random_03.txt AC 18 ms 38980 KB
random_04.txt AC 3 ms 7780 KB
random_05.txt AC 24 ms 38980 KB
random_06.txt AC 10 ms 21144 KB
random_07.txt AC 19 ms 38860 KB
random_08.txt AC 1 ms 4520 KB
random_09.txt AC 24 ms 38996 KB
random_10.txt AC 19 ms 33276 KB
random_11.txt AC 19 ms 38860 KB
random_12.txt AC 2 ms 6296 KB
random_13.txt AC 24 ms 38904 KB
random_14.txt AC 18 ms 32848 KB
random_15.txt AC 19 ms 38916 KB
random_16.txt AC 9 ms 20904 KB
random_17.txt AC 24 ms 38884 KB
random_18.txt AC 20 ms 34312 KB
random_19.txt AC 20 ms 38984 KB
random_20.txt AC 15 ms 32604 KB
random_21.txt AC 33 ms 38920 KB
random_22.txt AC 33 ms 38340 KB
random_23.txt AC 33 ms 38856 KB
random_24.txt AC 19 ms 38816 KB
random_25.txt AC 1 ms 3884 KB
sample_01.txt AC 1 ms 3784 KB
sample_02.txt AC 1 ms 3696 KB
sample_03.txt AC 1 ms 3824 KB


2025-03-05 (Wed)
20:49:38 +00:00