QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#709894#9522. A Simple String ProblemWrongAnswer_90AC ✓445ms181108kbC++237.1kb2024-11-04 17:20:022024-11-04 17:20:02

Judging History

你现在查看的是测评时间为 2024-11-04 17:20:02 的历史记录

  • [2024-11-10 22:38:12]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:AC
  • 用时:467ms
  • 内存:180344kb
  • [2024-11-10 22:36:11]
  • hack成功,自动添加数据
  • (/hack/1163)
  • [2024-11-06 21:49:54]
  • 自动重测本题所有获得100分的提交记录
  • 测评结果:100
  • 用时:670ms
  • 内存:181568kb
  • [2024-11-06 21:48:00]
  • hack成功,自动添加数据
  • (/hack/1142)
  • [2024-11-04 17:20:02]
  • 评测
  • 测评结果:100
  • 用时:445ms
  • 内存:181108kb
  • [2024-11-04 17:20:02]
  • 提交

answer

#include<bits/stdc++.h>
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define ll long long
#define lll __int128
#define fi first
#define se second
#define e emplace
#define eb emplace_back
#define db double
#define ef emplace_front
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vp vector<pii>
#define vt vector<tup>
#define all(x) x.begin(),x.end()
#define mp make_pair

#define FastI
#define FastO
#define int ll
bool ST;
static const ll MOD=998244353,Phi=998244352,inv2=499122177,Root=3,iRoot=332748118;
static const ll inf=1073741823,Inf=4294967296,INF=4557430888798830399;
static const ld eps=1e-9,pi=3.1415926535;
char in[200000030],*p1=in,*p2=in;
char out[1<<20],*p3=out;
using namespace std;
struct tup
{
	int x,y,z;
	tup(int X=0,int Y=0,int Z=0)
	{x=X,y=Y,z=Z;}
};
#ifdef FastI
#define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,200000030,stdin),p1==p2)?EOF:*p1++)
#endif
#ifdef FastO
#define putchar(x) (p3-out==1<<20?fwrite(out,1,1<<20,stdout),p3=out,0:0,*p3++=x)
#define puts(x) write(x,'\n')
#endif
namespace FastIO
{
	template<typename T> inline void write(T x,char ch=' ')
	{
		if(is_same<char,T>::value)putchar(x);
		else
		{
			if(x<0)x=-x,putchar('-');
			static char st[40];
			int top=0;
			do st[top++]=x%10+'0',x/=10;while(x);
			while(top)putchar(st[--top]);
		}
		ch!='~'?putchar(ch):0;
	}
	inline void write(const char*x,char ch=' ')
	{
		for(int i=0;x[i]!='\0';++i)putchar(x[i]);
		ch!='~'?putchar(ch):0;
	}
	inline void read(char&s){do s=getchar();while(s=='\n'||s==' ');}
	inline void read(char s[])
	{
		int len=0;char st;
		do st=getchar();while(st=='\n'||st==' ');
		s[++len]=st,st=getchar();
		while(st!='\n'&&st!=' '&&st!='\r'&&st!='\0')s[++len]=st,st=getchar();
		s[++len]='\0';
	}
	template<typename T> inline void read(T &s)
	{
		char ch=getchar();s=0;
		while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
		bool tf=(ch=='-'&&(ch=getchar()));
		while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
		s=tf?-s:s;
	}
	inline void edl(){putchar('\n');}
	template<typename T1,typename T2> inline void read(pair<T1,T2> &s){read(s.fi),read(s.se);}
	template<typename T,typename...Args> inline void write(T x,Args...args){write(x,'~'),write(args...);}
	template<typename T,typename...Args> inline void read(T&x,Args&...args){read(x),read(args...);}
	#ifdef FastO
	struct Writer{~Writer(){fwrite(out,1,p3-out,stdout);}}Writ;
	#endif
}
using namespace FastIO;
namespace MTool
{
	inline int Cadd(int a,int b){return (ll)a+b>=MOD?(ll)a+b-MOD:a+b;}
	inline int Cdel(int a,int b){return a-b<0?a-b+MOD:a-b;}
	inline int Cmul(int a,int b){return 1ll*a*b%MOD;}
	inline int sqr(int a){return 1ll*a*a%MOD;}
	inline void Madd(int&a,int b){a=((ll)a+b>=MOD?(ll)a+b-MOD:a+b);}
	inline void Mdel(int&a,int b){a=(a-b<0?a-b+MOD:a-b);}
	inline void Mmul(int&a,int b){a=1ll*a*b%MOD;}
	inline int Cmod(int x){return (x%MOD+MOD)%MOD;}
	inline void Mmod(int&x){x=(x%MOD+MOD)%MOD;}
	template<typename T> inline bool Mmax(T&a,T b){return a<b?a=b,1:0;}
	template<typename T> inline bool Mmin(T&a,T b){return a>b?a=b,1:0;}
	template<typename...Args> inline void Madd(int&a,int b,Args...args){Madd(a,b),Madd(a,args...);}
	template<typename...Args> inline void Mmul(int&a,int b,Args...args){Mmul(a,b),Mmul(a,args...);}
	template<typename...Args> inline void Mdel(int&a,int b,Args...args){Mdel(a,b),Mdel(a,args...);}
	template<typename...Args> inline int Cadd(int a,int b,Args...args){return Cadd(Cadd(a,b),args...);}
	template<typename...Args> inline int Cmul(int a,int b,Args...args){return Cmul(Cmul(a,b),args...);}
	template<typename...Args> inline int Cdel(int a,int b,Args...args){return Cdel(Cdel(a,b),args...);}
	template<typename...Args,typename T> inline bool Mmax(T&a,T b,Args...args){return Mmax(a,b)|Mmax(a,args...);}
	template<typename...Args,typename T> inline bool Mmin(T&a,T b,Args...args){return Mmin(a,b)|Mmin(a,args...);}
	inline int power(int x,int y){int s=1;for(;y;y>>=1,Mmul(x,x))if(y&1)Mmul(s,x);return s;}
}
using namespace MTool;
namespace WrongAnswer_90
{
	int n,m=128,F[21][800010],sa[800010],rk[800010],b[800010],x[1600010],y[1600010];
	int L[200010][2],R[200010][2];
	char t[2][200010],s[800010];
	inline int ask(int x,int y)
	{
		if(!x||!y)return 0;
	    if(x==y)return inf;
	    if((x=rk[x])>(y=rk[y]))swap(x,y);
	    int k=__lg(y-x++);
	    return min(F[k][x],F[k][y-(1<<k)+1]);
	}
	inline void SA(int n)
	{
	    for(int i=1;i<=n;++i)++b[x[i]=s[i]];
	    for(int i=2;i<=m;++i)b[i]+=b[i-1];
	    for(int i=1;i<=n;++i)sa[b[x[i]]--]=i;
	    for(int k=1,num=0;k<=n;k<<=1,num=0)
	    {
	        for(int i=n-k+1;i<=n;++i)y[++num]=i;
	        for(int i=1;i<=n;++i)if(sa[i]>k)y[++num]=sa[i]-k;
	        for(int i=1;i<=m;++i)b[i]=0;
	        for(int i=1;i<=n;++i)++b[x[i]];
	        for(int i=2;i<=m;++i)b[i]+=b[i-1];
	        for(int i=n;i>=1;--i)sa[b[x[y[i]]]--]=y[i];
	        swap(x,y),x[sa[1]]=1;
	        for(int i=2;i<=n;++i)
	        {
	            if(y[sa[i]]==y[sa[i-1]]&&y[sa[i]+k]==y[sa[i-1]+k])x[sa[i]]=x[sa[i-1]];
	            else x[sa[i]]=x[sa[i-1]]+1;
	        }
	        if((m=x[sa[n]])==n)break;
	    }
	    for(int i=1;i<=n;++i)rk[sa[i]]=i;
	    for(int i=1,k=0;i<=n;++i,k?--k:0)
	    {
	        while(s[i+k]==s[sa[rk[i]-1]+k])++k;
	        F[0][rk[i]]=k;
	    }
	    for(int i=1;i<=20;++i)
	    {
	        for(int j=1;j+(1<<i)-1<=n;++j)
	        F[i][j]=min(F[i-1][j],F[i-1][j+(1<<(i-1))]);
	    }
	}
	
	void mian()
	{
		read(n),++n;
		read(t[0]),t[0][n]='?';
		read(t[1]+1),t[1][1]='!';
		int len=0;
		for(int i=1;i<=n;++i)s[++len]=t[0][i],R[i][0]=len;s[++len]='#';
		for(int i=1;i<=n;++i)s[++len]=t[1][i],R[i][1]=len;s[++len]='$';
		for(int i=1;i<=n;++i)s[++len]=t[0][n-i+1],L[n-i+1][0]=len;s[++len]='*';
		for(int i=1;i<=n;++i)s[++len]=t[1][n-i+1],L[n-i+1][1]=len;
//		for(int i=1;i<=n;++i)cerr<<t[0][i];cerr<<endl;
//		for(int i=1;i<=n;++i)cerr<<t[1][i];cerr<<endl;
		SA(len);
//		cerr<<ask(L[3][1],L[6][1])<<endl;
//		cerr<<ask(R[4][1],R[7][1])<<endl;
//		exit(0);
		for(int i=n/2;i>=1;--i)
		{
			for(int x=i,y=2*i;y<=n;x+=i,y+=i)
			{
				int r=ask(R[x+1][1],R[y+1][1]);
				int l=ask(L[x][1],L[y][1]);
				l+=ask(L[x-l][0],L[y-l][1]);
//				cerr<<"???";
				if(l+r>=i)return write(i<<1);
				l=ask(L[x][0],L[y][0]);
				r=ask(R[x+1][0],R[y+1][0]);
				r+=ask(R[x+1+r][0],R[y+1+r][1]);
				if(l+r>=i)return write(i<<1);
				r=ask(R[x+1][0],R[y+1][1]);
				r+=ask(R[x+1+r][1],R[y+1+r][1]);
				l=ask(L[x][0],L[y][1]);
				if(l+r>=i)return write(i<<1);
				r=ask(R[x+1][0],R[y+1][1]);
				l=ask(L[x][0],L[y][1]);
				l+=ask(L[x-l][0],L[y-l][0]);
				if(l+r>=i)return write(i<<1);
			}
		}
		puts("0");
	}
	inline void Mian()
	{
		int T=1;
//		read(T);
		while(T--)mian();
	}
}
bool ED;
signed main()
{
//	ios::sync_with_stdio(0);
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	double st=clock();
	WrongAnswer_90::Mian();
	double ed=clock();
 	cerr<<endl;
 	cerr<<"Time: "<<ed-st<<" ms\n";
 	cerr<<"Memory: "<<abs(&ST-&ED)/1024.0/1024.0<<" MB\n";
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 53056kb

input:

5
abcab
acabc

output:

6 

result:

ok single line: '6 '

Test #2:

score: 0
Accepted
time: 0ms
memory: 51076kb

input:

6
babbaa
babaaa

output:

6 

result:

ok single line: '6 '

Test #3:

score: 0
Accepted
time: 0ms
memory: 46988kb

input:

2
ne
fu

output:

0

result:

ok single line: '0'

Test #4:

score: 0
Accepted
time: 7ms
memory: 51024kb

input:

6
baabba
baabab

output:

4 

result:

ok single line: '4 '

Test #5:

score: 0
Accepted
time: 4ms
memory: 49032kb

input:

6
aaabba
aabbba

output:

2 

result:

ok single line: '2 '

Test #6:

score: 0
Accepted
time: 3ms
memory: 48976kb

input:

6
abaabb
bbbaba

output:

4 

result:

ok single line: '4 '

Test #7:

score: 0
Accepted
time: 299ms
memory: 180936kb

input:

200000
wvblpxtatzytphgshchrevqqpnbljlorfoqubygysrivtemegmgrepemnlcbfqalpqqpvuockkbbvjnouhcerxqibevbipsxuscjejlcdtxoxipwrfrjwnriubvdgdgzlydwwiueovtrzljqxwfegejukncmahbcbsraxboukdesrzbwfvbpxpdntauidrybccwaocfwntohdkhxkfqhnoccyaylvvfebckmslrthubxrxvjoqcredanofbmgtsnswgszwhjckqeiddzvpnxphjkrwlsbthdvhzgn...

output:

200000 

result:

ok single line: '200000 '

Test #8:

score: 0
Accepted
time: 286ms
memory: 180428kb

input:

199999
klwumjcvuqinrkcsyvgfixhwvrwbmazkclblcnlpyxtlmmpkllkpukmxaurpukvgibcsuigcoqnnreivrlrwfdqofqcwubpolnnxcansyaevdjvnhnzvjeoejktaodusltockhtuqrohqfsrezdzurowghmcateztzlltkzlqynxpgbqsvgqtpukmfgdxopynqaegmjxvjixyzjrhbgahxwkswgpanhrdgpyvtvcpsihdvmtixfskuiprfqrfknohthfblkzlrcyqewdycoljgwrhjkmoxqmtogmg...

output:

200000 

result:

ok single line: '200000 '

Test #9:

score: 0
Accepted
time: 288ms
memory: 180704kb

input:

200000
yagcbqaxecsgdijvsdsqlemrrhyyuysvlbkkgultlmrapzokempkzmyyvgabgtqifgqhwyudzbkbjncsuixvyffpvtuczjakknocyskvqaohfvxomjhzirykpdwisgkmyomejaxbzamrnfcxjwjouskvjfuriurzknmhfvpvbdqunfckdmxhndvffhuybezncgohzwxvwfscltbhwvgvbrrejtuixsdwetkdxlogepphsvhyzybisqixsledftgegzbslkqsalhoifysrxsbjxvpojjxkqqoumlkj...

output:

114514 

result:

ok single line: '114514 '

Test #10:

score: 0
Accepted
time: 445ms
memory: 180820kb

input:

200000
cbacabcbabcacbacabcacbabcbacabcbabcacbabcbacabcacbacabcbabcacbacabcacbabcbacabcacbacabcbabcacbabcbacabcbabcacbacabcacbabcbacabcbabcacbabcbacabcacbacabcbabcacbabcbacabcbabcacbacabcacbabcbacabcacbacabcbabcacbacabcacbabcbacabcbabcacbabcbacabcacbacabcbabcacbacabcacbabcbacabcacbacabcbabcacbabcbaca...

output:

0

result:

ok single line: '0'

Test #11:

score: 0
Accepted
time: 218ms
memory: 180020kb

input:

200000
bbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbababbabbababbabbababbababbabbababbabbababbababbabbababbababbabbaba...

output:

150050 

result:

ok single line: '150050 '

Test #12:

score: 0
Accepted
time: 237ms
memory: 180632kb

input:

200000
babababbaaaaaaabbbaaabbbbaaabbaaaabbaababbabbbbbababbbabbbaaabaaabaabbaabbaabbabbaaaaaababbbbbbaaaabaababbabaaabbbbbbabaaaabaaabaaaababaaabbbbbbaaabaabaaabbabbbabbbabaaaabbbbbbabbaabbaaaaaaaaabababbabbbbbaabaabaaabababbaabbbbbbabbaaaaababaabbaaaabbbbaaababbabbaabaabaabaaabbabaaaaabbabababbbaa...

output:

131072 

result:

ok single line: '131072 '

Test #13:

score: 0
Accepted
time: 336ms
memory: 181108kb

input:

200000
rhqtphowacdrsxqisrqjhcsmxvwqtbmsvawxxxujgibnowkeyzhnjihsvsuklueukevgvlfqnrhalhglqlknerjwzizhxxszwjtnroubsjdhbnekbolwxaigyeypumuncdhmqqeljoyewehkhsqfoirchdnwazypwtefdyvtockpluejsftmffgbgdcotjnnkimawpflzwurdwrmpeudobzhpoyktufkgyvxpbfhuzswkrmnfzultfxdefoffvrfmuoufylyfvexnxgwgqfbiqvwpyenoqxncisuz...

output:

8 

result:

ok single line: '8 '

Test #14:

score: 0
Accepted
time: 3ms
memory: 55172kb

input:

10
aaabaabaaa
aabbbaaaba

output:

6 

result:

ok single line: '6 '

Test #15:

score: 0
Accepted
time: 4ms
memory: 53168kb

input:

17
ababbbaabbbaaaaba
abbabbbbbaabaabba

output:

10 

result:

ok single line: '10 '

Test #16:

score: 0
Accepted
time: 4ms
memory: 55172kb

input:

22
aaabbbaaaababbabbbbbbb
bbaabbbbbaaabbbabaaaaa

output:

8 

result:

ok single line: '8 '

Test #17:

score: 0
Accepted
time: 12ms
memory: 55124kb

input:

15
abaabaaaaabbbab
abbbabbbabababa

output:

8 

result:

ok single line: '8 '

Test #18:

score: 0
Accepted
time: 3ms
memory: 53060kb

input:

5
aabba
baaba

output:

6 

result:

ok single line: '6 '

Test #19:

score: 0
Accepted
time: 0ms
memory: 49008kb

input:

1
a
a

output:

2 

result:

ok single line: '2 '

Test #20:

score: 0
Accepted
time: 4ms
memory: 59272kb

input:

100
baabaaaabaabaabaaabaabbbabbbbbaababbabbbabbbbababaaabbabbaaaabbbaaabaabbbaaaaaababaababbbbbaaabbaabb
abbbbbbbbaaaaababbabbabbbbbaaaabbabbbaaaaabababbbabbababbbabbaabbabbabbbaaababbabbabbabbbabbbababaaa

output:

20 

result:

ok single line: '20 '

Test #21:

score: 0
Accepted
time: 8ms
memory: 59272kb

input:

32
babbbbbabbababaabbbaaaaabbaababa
abbbaaababaabababbaaabaaabbaaaab

output:

18 

result:

ok single line: '18 '

Extra Test:

score: 0
Extra Test Passed