QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#471011#1281. Longest Common Subsequencezhouyuxuan3501Compile Error//C++983.4kb2024-07-10 17:15:312024-07-10 17:15:32

Judging History

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

  • [2024-07-10 17:15:32]
  • 评测
  • [2024-07-10 17:15:31]
  • 提交

answer

#pragma GCC optimize(2)
#include<cstdio>
#include<algorithm>
using namespace std;
const int n_max=1e6+11;
struct BIT
{
	int t[n_max<<1],N;
	void Z(int x,int c)
	{
		for(;x<=N;x+=(-x&x))
			t[x]=max(t[x],c);
	}
	int C(int x)
	{
		int c=0;
		for(;x;x-=(-x&x))
			c=max(c,t[x]);
		return c;
	}
}T1,T2;
int Du()
{
	int k=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')
	{
		k=k*10+c-'0';
		c=getchar();
	}
	return k;
}
int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
void CN()
{
	n=Du();   m=Du();   T1.N=T2.N=n+m+1;
	for(i=0;i<=n+m+1;i++)T1.t[i]=T2.t[i]=0;
	for(i=1;i<=n;i++)
	{
		A[i]=Du();
		if(A[i]==1)c1[0][++k1[0]]=i;
		c2[0][i]=c2[0][i-1]+(A[i]==2);
	}
	for(i=n;i>=1;i--)if(A[i]==3)c3[0][++k3[0]]=i;
	c3[0][0]=n+1;   c2[0][n+1]=c2[0][n];
	for(i=1;i<=m;i++)
	{
		B[i]=Du();
		if(B[i]==1)c1[1][++k1[1]]=i;
		c2[1][i]=c2[1][i-1]+(B[i]==2); 
	}
	for(i=m;i>=1;i--)if(B[i]==3)c3[1][++k3[1]]=i;
	c3[1][0]=m+1;   c2[1][m+1]=c2[1][m];
	h=min(k1[0],k1[1]);   w=min(k3[0],k3[1]);   j=0;
	for(i=h;i>=0;i--)
	{
		while(j<=w&&c3[0][j]>c1[0][i]&&c3[1][j]>c1[1][i])
		{
			T1.Z(c2[0][c3[0][j]]-c2[1][c3[1][j]]+m+1,j+c2[0][c3[0][j]]);
			j++;
		}
		y=max(y,T1.C(c2[0][c1[0][i]]-c2[1][c1[1][i]]+m+1)+i-c2[0][c1[0][i]]);
	}
	j=0;
	for(i=h;i>=0;i--)
	{
		while(j<=w&&c1[0][i]<c3[0][j]&&c1[1][i]<c3[1][j])
		{
			T2.Z(c2[1][c3[1][j]]-c2[0][c3[0][j]]+n+1,j+c2[1][c3[1][j]]);
			j++;
		}
		y=max(y,T2.C(c2[1][c1[1][i]]-c2[0][c1[0][i]]+n+1)+i-c2[1][c1[1][i]]);
	}
	printf("%d\n",y);
}
int main()
{
	t=Du();
	while(t--)
	{
		k1[0]=k1[1]=k3[0]=k3[1]=0;
		y=0;
		CN();
	}
	return 0;
}#pragma GCC optimize(2)
#include<cstdio>
#include<algorithm>
using namespace std;
const int n_max=1e6+11;
struct BIT
{
	int t[n_max<<1],N;
	void Z(int x,int c)
	{
		for(;x<=N;x+=(-x&x))
			t[x]=max(t[x],c);
	}
	int C(int x)
	{
		int c=0;
		for(;x;x-=(-x&x))
			c=max(c,t[x]);
		return c;
	}
}T1,T2;
int Du()
{
	int k=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')
	{
		k=k*10+c-'0';
		c=getchar();
	}
	return k;
}
int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
void CN()
{
	n=Du();   m=Du();   T1.N=T2.N=n+m+1;
	for(i=0;i<=n+m+1;i++)T1.t[i]=T2.t[i]=0;
	for(i=1;i<=n;i++)
	{
		A[i]=Du();
		if(A[i]==1)c1[0][++k1[0]]=i;
		c2[0][i]=c2[0][i-1]+(A[i]==2);
	}
	for(i=n;i>=1;i--)if(A[i]==3)c3[0][++k3[0]]=i;
	c3[0][0]=n+1;   c2[0][n+1]=c2[0][n];
	for(i=1;i<=m;i++)
	{
		B[i]=Du();
		if(B[i]==1)c1[1][++k1[1]]=i;
		c2[1][i]=c2[1][i-1]+(B[i]==2); 
	}
	for(i=m;i>=1;i--)if(B[i]==3)c3[1][++k3[1]]=i;
	c3[1][0]=m+1;   c2[1][m+1]=c2[1][m];
	h=min(k1[0],k1[1]);   w=min(k3[0],k3[1]);   j=0;
	for(i=h;i>=0;i--)
	{
		while(j<=w&&c3[0][j]>c1[0][i]&&c3[1][j]>c1[1][i])
		{
			T1.Z(c2[0][c3[0][j]]-c2[1][c3[1][j]]+m+1,j+c2[0][c3[0][j]]);
			j++;
		}
		y=max(y,T1.C(c2[0][c1[0][i]]-c2[1][c1[1][i]]+m+1)+i-c2[0][c1[0][i]]);
	}
	j=0;
	for(i=h;i>=0;i--)
	{
		while(j<=w&&c1[0][i]<c3[0][j]&&c1[1][i]<c3[1][j])
		{
			T2.Z(c2[1][c3[1][j]]-c2[0][c3[0][j]]+n+1,j+c2[1][c3[1][j]]);
			j++;
		}
		y=max(y,T2.C(c2[1][c1[1][i]]-c2[0][c1[0][i]]+n+1)+i-c2[1][c1[1][i]]);
	}
	printf("%d\n",y);
}
int main()
{
	t=Du();
	while(t--)
	{
		k1[0]=k1[1]=k3[0]=k3[1]=0;
		y=0;
		CN();
	}
	return 0;
}

詳細信息

answer.code:87:2: error: stray ‘#’ in program
   87 | }#pragma GCC optimize(2)
      |  ^
answer.code:87:3: error: ‘pragma’ does not name a type; did you mean ‘_Pragma’?
   87 | }#pragma GCC optimize(2)
      |   ^~~~~~
      |   _Pragma
answer.code:91:11: error: redefinition of ‘const int n_max’
   91 | const int n_max=1e6+11;
      |           ^~~~~
answer.code:5:11: note: ‘const int n_max’ previously defined here
    5 | const int n_max=1e6+11;
      |           ^~~~~
answer.code:92:8: error: redefinition of ‘struct BIT’
   92 | struct BIT
      |        ^~~
answer.code:6:8: note: previous definition of ‘struct BIT’
    6 | struct BIT
      |        ^~~
answer.code:107:2: error: conflicting declaration ‘int T1’
  107 | }T1,T2;
      |  ^~
answer.code:21:2: note: previous declaration as ‘BIT T1’
   21 | }T1,T2;
      |  ^~
answer.code:107:5: error: conflicting declaration ‘int T2’
  107 | }T1,T2;
      |     ^~
answer.code:21:5: note: previous declaration as ‘BIT T2’
   21 | }T1,T2;
      |     ^~
answer.code:108:5: error: redefinition of ‘int Du()’
  108 | int Du()
      |     ^~
answer.code:22:5: note: ‘int Du()’ previously defined here
   22 | int Du()
      |     ^~
answer.code:120:5: error: redefinition of ‘int n’
  120 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |     ^
answer.code:34:5: note: ‘int n’ previously declared here
   34 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |     ^
answer.code:120:7: error: redefinition of ‘int m’
  120 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |       ^
answer.code:34:7: note: ‘int m’ previously declared here
   34 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |       ^
answer.code:120:9: error: redefinition of ‘int t’
  120 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |         ^
answer.code:34:9: note: ‘int t’ previously declared here
   34 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |         ^
answer.code:120:11: error: redefinition of ‘int A [1000011]’
  120 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |           ^
answer.code:34:11: note: ‘int A [1000011]’ previously declared here
   34 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |           ^
answer.code:120:20: error: redefinition of ‘int B [1000011]’
  120 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |                    ^
answer.code:34:20: note: ‘int B [1000011]’ previously declared here
   34 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |                    ^
answer.code:120:29: error: redefinition of ‘int c1 [2][1000011]’
  120 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |                             ^~
answer.code:34:29: note: ‘int c1 [2][1000011]’ previously declared here
   34 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |                             ^~
answer.code:120:42: error: redefinition of ‘int c2 [2][1000011]’
  120 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |                                          ^~
answer.code:34:42: note: ‘int c2 [2][1000011]’ previously declared here
   34 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |                                          ^~
answer.code:120:55: error: redefinition of ‘int c3 [2][1000011]’
  120 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |                                                       ^~
answer.code:34:55: note: ‘int c3 [2][1000011]’ previously declared here
   34 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |                                                       ^~
answer.code:120:68: error: redefinition of ‘int i’
  120 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |                                                                    ^
answer.code:34:68: note: ‘int i’ previously declared here
   34 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |                                                                    ^
answer.code:120:70: error: redefinition of ‘int j’
  120 | int n,m,t,A[n_max],B[n_max],c1[2][n_max],c2[2][n_max],c3[2][n_max],i,j,h,w,y,k1[2],k3[2];
      |                                                                      ^
answer.code:34:70: note: ‘int j’ previously declared here
...