QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#278098 | #7877. Balanced Array | Vegetable_Dog# | WA | 13ms | 36992kb | C++23 | 1.4kb | 2023-12-07 12:04:31 | 2023-12-07 12:04:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
int read(){
int f=0,s=0; char c=getchar();
while(c>'9'||c<'0')f=(c=='-'),c=getchar();
while(c>='0'&&c<='9')s=(s<<3)+(s<<1)+(c^'0'),c=getchar();
return f?-s:s;
}
char tmp[35];
int readd(){
scanf("%s",tmp+1);
int len=strlen(tmp+1);
int res=0;
for(int i=1;i<=len;i++){
res*=62;
if(tmp[i]>='0'&&tmp[i]<='9')res+=tmp[i]-'0';
else if(islower(tmp[i]))res+=(tmp[i]-'a')+10;
else if(isupper(tmp[i]))res+=(tmp[i]-'A')+36;
}
return res;
}
const int N=2000005;
int n;
int a[N];
int b[N];
const ull bs=131;
ull pw[N];
ull hs[N];
ull get(int l,int r){
if(l>r)return 0;
return hs[r]-hs[l-1]*pw[r-l+1];
}
int now=1;
bool chk(int k,int len){
int dt=len-(1+2*k)-1;
ull t1=get(1,1+dt);
ull t2=get(1+2*k,1+2*k+dt);
ull t3=get(1+k,1+k+dt);
return t1+t2==2*t3;
}
bool check(int len){
while(1+2*now<=len&&!chk(now,len))now++;
if(1+2*now>len)return 0;
return 1;
}
int main(){
n=read();
for(int i=1;i<=n;i++){
a[i]=readd();
// cout<<i<<' '<<a[i]<<endl;
// if(i%10000==0)cout<<i<<endl;
}
// puts("ER");
for(int i=1;i<=n;i++)b[i]=a[i]-a[i+1];
pw[0]=1; for(int i=1;i<N;i++)pw[i]=pw[i-1]*bs;
hs[0]=0; for(int i=1;i<N;i++)hs[i]=hs[i-1]*bs+b[i];
for(int i=1;i<=n;i++){
if(check(i))putchar('1');
else putchar('0');
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 8ms
memory: 36872kb
input:
3 1 2 3
output:
001
result:
ok single line: '001'
Test #2:
score: 0
Accepted
time: 13ms
memory: 36992kb
input:
9 1 2 3 2 5 4 3 8 5
output:
001010111
result:
ok single line: '001010111'
Test #3:
score: 0
Accepted
time: 8ms
memory: 36868kb
input:
9 1C 3f 4S 3h 88 6x 4W d1 8c
output:
001010111
result:
ok single line: '001010111'
Test #4:
score: -100
Wrong Answer
time: 8ms
memory: 36988kb
input:
49 71FjQ 71FzG 71FjR 71FjG 71FjS 71F3G 71FjT 71ENG 71FjU 71ExG 71FzG 71Fko 71FjW 71FOM 71FPm 71FzG 71FPO 71FP9 71FzG 71Fkc 71FzG 7AXBr 71FPH 8nKLh 71Fk2 71FzG 71FkK 4AGIE 71Fk9 6EfCL 71FPN 71FjJ 71FPb 7H3TC 71Gks 71FzG 71FPI 71FzG 6Oayg 71FPc 71FPw 71FPN 71Fkm 71FPK 71FPK 6Az4J 71FPI 71FzG 71Fke
output:
0010111111101010101010101010101010111010101010101
result:
wrong answer 1st lines differ - expected: '0000111111001000000000001000000000110000100000001', found: '0010111111101010101010101010101010111010101010101'