QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#444109#8521. Pattern Search IIucup-team3510#Compile Error//C++201.3kb2024-06-15 17:20:472024-06-15 17:20:49

Judging History

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

  • [2024-06-15 17:20:49]
  • 评测
  • [2024-06-15 17:20:47]
  • 提交

answer

#include <bits/stdc++.h>
#define N 5000011
using namespace std;
char s[N];int n,ch[N*2][2],ed[N*2],link[N*2],len[N*2],siz[N*2],lst,sz;long long ans;
void saminit(){link[0]=-1;len[0]=0;lst=0;}
void append(char s)
{
	int nw=++sz;ed[sz]=1;len[nw]=len[lst]+1;int p=lst;lst=nw;
	while(~p&&!ch[p][s-'a'])ch[p][s-'a']=nw,p=link[p];
	if(!~p){link[nw]=0;return;}
	int q=ch[p][s-'a'];
	if(len[p]+1==len[q])link[lst]=q;
	else
	{
		int cl=++sz;
		link[cl]=link[q];
		for(int i=0;i<2;++i)ch[cl][i]=ch[q][i];
		len[cl]=len[p]+1;
		link[q]=link[nw]=cl;
		while(~p&&ch[p][s-'a']==q)ch[p][s-'a']=cl,p=link[p];
	}
}
char S[N],nS[N];
const int B=5e6;
void dfs(int u,int cur,int len)
{//printf("dfs(%d,%d,%d)\n",u,cur,len);
	if(u==n+1){printf("%d\n",len);exit(0);}
	if(ch[cur][s[u]-'a'])dfs(u+1,ch[cur][s[u]-'a'],len+1);
	if(ch[cur][!(s[u]-'a')])dfs(u,ch[cur][!(s[u]-'a')],len+1);
}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	int cnt0=1,cnt1=0;S[1]='a';
	while(cnt0*2+cnt1<=B)
	{
		int nc=0;
		for(int i=1;i<=cnt0+cnt1;++i)
		{
			if(S[i]=='b')nS[++nc]='a';
			else nS[++nc]='a',nS[++nc]='b';
		}
		cnt0=cnt1=0;
		for(int i=1;i<=nc;++i)S[i]=nS[i],cnt0+=S[i]=='a',cnt1+=S[i]=='b';
	}
//	printf("S:%s\n",S+1);
	saminit();
	for(int i=1;i<=cnt0+cnt1;++i)append(S[i]);
	dfs(1,0,0);
}

詳細信息

answer.code:4:44: error: ‘int link [10000022]’ redeclared as different kind of entity
    4 | char s[N];int n,ch[N*2][2],ed[N*2],link[N*2],len[N*2],siz[N*2],lst,sz;long long ans;
      |                                            ^
In file included from /usr/include/c++/13/bits/atomic_wait.h:44,
                 from /usr/include/c++/13/bits/atomic_base.h:42,
                 from /usr/include/c++/13/bits/shared_ptr_atomic.h:33,
                 from /usr/include/c++/13/memory:81,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:56,
                 from answer.code:1:
/usr/include/unistd.h:789:12: note: previous declaration ‘int link(const char*, const char*)’
  789 | extern int link (const char *__from, const char *__to)
      |            ^~~~
answer.code: In function ‘void saminit()’:
answer.code:5:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    5 | void saminit(){link[0]=-1;len[0]=0;lst=0;}
      |                      ^
answer.code:5:23: error: assignment of read-only location ‘* link’
    5 | void saminit(){link[0]=-1;len[0]=0;lst=0;}
      |                ~~~~~~~^~~
answer.code: In function ‘void append(char)’:
answer.code:9:57: warning: pointer to a function used in arithmetic [-Wpointer-arith]
    9 |         while(~p&&!ch[p][s-'a'])ch[p][s-'a']=nw,p=link[p];
      |                                                         ^
answer.code:9:57: error: invalid conversion from ‘int (*)(const char*, const char*) noexcept’ to ‘int’ [-fpermissive]
    9 |         while(~p&&!ch[p][s-'a'])ch[p][s-'a']=nw,p=link[p];
      |                                                   ~~~~~~^
      |                                                         |
      |                                                         int (*)(const char*, const char*) noexcept
answer.code:10:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   10 |         if(!~p){link[nw]=0;return;}
      |                        ^
answer.code:10:25: error: assignment of read-only location ‘*(link + ((sizetype)nw))’
   10 |         if(!~p){link[nw]=0;return;}
      |                 ~~~~~~~~^~
answer.code:12:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   12 |         if(len[p]+1==len[q])link[lst]=q;
      |                                     ^
answer.code:12:38: error: assignment of read-only location ‘*(link + ((sizetype)lst))’
   12 |         if(len[p]+1==len[q])link[lst]=q;
      |                             ~~~~~~~~~^~
answer.code:16:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |                 link[cl]=link[q];
      |                        ^
answer.code:16:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   16 |                 link[cl]=link[q];
      |                                ^
answer.code:16:25: error: assignment of read-only location ‘*(link + ((sizetype)cl))’
   16 |                 link[cl]=link[q];
      |                 ~~~~~~~~^~~~~~~~
answer.code:19:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   19 |                 link[q]=link[nw]=cl;
      |                       ^
answer.code:19:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   19 |                 link[q]=link[nw]=cl;
      |                                ^
answer.code:19:33: error: assignment of read-only location ‘*(link + ((sizetype)nw))’
   19 |                 link[q]=link[nw]=cl;
      |                         ~~~~~~~~^~~
answer.code:20:67: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   20 |                 while(~p&&ch[p][s-'a']==q)ch[p][s-'a']=cl,p=link[p];
      |                                                                   ^
answer.code:20:67: error: invalid conversion from ‘int (*)(const char*, const char*) noexcept’ to ‘int’ [-fpermissive]
   20 |                 while(~p&&ch[p][s-'a']==q)ch[p][s-'a']=cl,p=link[p];
      |                                                             ~~~~~~^
      |                                                                   |
      |                                                                   int (*)(const char*, const char*) noexcept
answer.code: In function ‘int main()’:
answer.code:33:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   33 |         scanf("%s",s+1);n=strlen(s+1);
      |         ~~~~~^~~~~~~~~~