QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#72219 | #4273. Good Game | Pittow | 0 | 7ms | 16580kb | C++14 | 1.3kb | 2023-01-15 09:47:33 | 2023-01-15 09:47:34 |
Judging History
answer
#include<stdio.h>
typedef unsigned int u32;
u32 n,i,a[1000086];
u32 m,j,s[1000086],g[1000086];
u32 c,p[500086],u[500086];
void del(u32 x,u32 l){
u[c]=l;
p[c++]=x;
}void print(){
for(i=0;i<c;++i)n-=u[i];
if(n)c=0;
if(c==0){
puts("-1");
return;
}printf("%u\n",c);
for(i=0;i<c;++i)
printf("%u %u\n",p[i]+1,u[i]);
}void clear(u32 p,u32 l){
if(l&1)del(p,3),l-=3;
while(l)del(p,2),l-=2;
}void odd(u32 *s,u32 m){
g[0]=s[0];
for(i=1;i<m;++i)g[i]=g[i-1]+s[i];
if(s[m>>1]>1){
clear(g[m>>1]-s[m>>1],s[m>>1]);
for(i=(m>>1)-1;i<m;--i)
clear(g[i]-s[i],s[i]+s[m-1-i]);
}else{
for(i=m>>1;i&&s[i-1]==1;--i);
for(j=m>>1;j<m&&s[j]==1;++j);
if((j-i)*2<m){
clear(g[j]-s[j],s[j]);
for(u32 k=j+1;k+1<m&&j+j>i+i+k;++k)
clear(g[k]-s[k],s[k]+s[j+j-k]);
if(i)clear(g[i-1]-s[i-1],s[i-1]);
for(u32 k=i-2;k&&k<m;--k)
clear(g[k]-s[k],s[k]+s[i+i-k]);
clear(0,s[0]+s[i+i]+s[m-1]);
}
}
}int main(){
scanf("%u",&n);
for(i=0;i<n;++i){
char c;
while(c=getchar(),c<'A'||c>'B');
if(c=='A')a[i]=1;
}for(i=j=0;i<n;i=j,++m)
while(j<n&&a[j]==a[i])++j,++s[m];
if(a[0]==a[n-1])odd(s,m);
else if(s[0]>1||s[m-1]>1){
if(s[0]>1)clear(0,s[0]),odd(s+1,m-1);
else clear(n-s[m-1],s[m-1]),odd(s,m-1);
}else odd(s,m>>1),odd(s+(m>>1),m>>1);
print();
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 3
Accepted
time: 1ms
memory: 7720kb
input:
9 ABAABBBAA
output:
4 3 2 2 2 2 2 1 3
result:
ok good solution!
Test #2:
score: -3
Wrong Answer
time: 0ms
memory: 9620kb
input:
13 ABABBABABBABA
output:
-1
result:
wrong answer you didn't find a solution but jury did
Subtask #2:
score: 0
Wrong Answer
Test #51:
score: 6
Accepted
time: 3ms
memory: 9660kb
input:
299 ABABABABABABABABABABABABABABABABABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...
output:
-1
result:
ok no solution
Test #52:
score: 0
Accepted
time: 2ms
memory: 9676kb
input:
300 ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAB...
output:
-1
result:
ok no solution
Test #53:
score: -6
Wrong Answer
time: 2ms
memory: 9576kb
input:
299 ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABBBBBBABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...
output:
-1
result:
wrong answer you didn't find a solution but jury did
Subtask #3:
score: 0
Wrong Answer
Test #102:
score: 0
Wrong Answer
time: 1ms
memory: 7640kb
input:
5998 BABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB...
output:
-1
result:
wrong answer you didn't find a solution but jury did
Subtask #4:
score: 0
Wrong Answer
Test #153:
score: 0
Wrong Answer
time: 7ms
memory: 16580kb
input:
999997 ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA...
output:
-1
result:
wrong answer you didn't find a solution but jury did