QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#478174#7877. Balanced Arrayucup-team4352Compile Error//C++231.8kb2024-07-14 18:12:092024-07-14 18:12:09

Judging History

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

  • [2024-07-14 18:12:09]
  • 评测
  • [2024-07-14 18:12:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=2e6+5;
const ll mod=2000298369ll*31;
inline int read() {
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*f;
}
int n,a[maxn];
typedef long long ll;
ll qp[maxn],sum[maxn];
ll query(int l,int r) {
	ll tmp=sum[r]-sum[l-1]*qp[r-l+1]%mod;
	if(tmp<0) tmp+=mod;
	return tmp;
}
int Min[maxn];
bool check(int x,int y,int k,int len) {
	ll tmp1=query(y,y+len-1)-query(y-k,y-k+len-1);
	if(tmp1<0) tmp1+=mod;
	ll tmp2=query(x,x+len-1)-query(1,len);
	if(tmp2<0) tmp2+=mod;
	if(tmp1==tmp2) return 1;
	return 0;
}
inline int get_num(char c){
    if(c>='0'&&c<='9')return c-48;
    if(c>='a'&&c<='z')return c-'a'+10;
    if(c>='A'&&c<='Z')return c-'A'+36;
    return -1;
}
inline int readc() {
    int x=0,f=1;
    char ch=getchar();
    while(get_num(ch)==-1) {if(ch=='-') f=-1;ch=getchar();}
    while(get_num(ch)!=-1) {x=x*62+get_num(ch);ch=getchar();}
    return x*f;
}
int main() {
	n=read();
	qp[0]=1;
	for(int i=1;i<=n;++i) {
		a[i]=readc();
		qp[i]=qp[i-1]*233ull;
		qp[i]%=mod;
		sum[i]=sum[i-1]*233ull+a[i];
		sum[i]%=mod;
		Min[i]=i;
	}
	for(int k=1;k<=(n-1)/2;++k) {
		ll now=query(k+1,k*2)-query(1,k);
		if(now<0) now+=mod; 
		int p=2;
		for(int len=3;len*k<=n;++len) {
			ll tmp=query((len-1)*k+1,len*k)-query((len-2)*k+1,(len-1)*k);
			if(tmp<0) tmp+=mod;
			if(tmp!=now) break;
			p=len;
		}
		int l=p*k+1,r=min((p+1)*k,n);
		while(l<=r) {
			int mid=l+r>>1;
			if(check(k+1,p*k+1,k,mid-p*k)) l=mid+1;
			else r=mid-1;
		}
		if((r-1)/2>=k) Min[r]=min(Min[r],k);
	}
	for(int i=n-1;i;--i) Min[i]=min(Min[i+1],Min[i]);
	for(int i=1;i<=n;++i) {
		if(Min[i]<=(i-1)/2) putchar('1');
		else putchar('0');
	}
	return 0;
}

Details

answer.code:4:7: error: ‘ll’ does not name a type
    4 | const ll mod=2000298369ll*31;
      |       ^~
answer.code: In function ‘ll query(int, int)’:
answer.code:16:42: error: ‘mod’ was not declared in this scope; did you mean ‘modf’?
   16 |         ll tmp=sum[r]-sum[l-1]*qp[r-l+1]%mod;
      |                                          ^~~
      |                                          modf
answer.code: In function ‘bool check(int, int, int, int)’:
answer.code:23:26: error: ‘mod’ was not declared in this scope; did you mean ‘modf’?
   23 |         if(tmp1<0) tmp1+=mod;
      |                          ^~~
      |                          modf
answer.code:25:26: error: ‘mod’ was not declared in this scope; did you mean ‘modf’?
   25 |         if(tmp2<0) tmp2+=mod;
      |                          ^~~
      |                          modf
answer.code: In function ‘int main()’:
answer.code:48:24: error: ‘mod’ was not declared in this scope; did you mean ‘modf’?
   48 |                 qp[i]%=mod;
      |                        ^~~
      |                        modf
answer.code:55:32: error: ‘mod’ was not declared in this scope; did you mean ‘modf’?
   55 |                 if(now<0) now+=mod;
      |                                ^~~
      |                                modf
answer.code:59:40: error: ‘mod’ was not declared in this scope; did you mean ‘modf’?
   59 |                         if(tmp<0) tmp+=mod;
      |                                        ^~~
      |                                        modf