QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#263463 | #6185. Best Problem | Crysfly | AC ✓ | 59ms | 77072kb | C++17 | 2.4kb | 2023-11-24 21:09:07 | 2024-04-05 16:19:21 |
Judging History
answer
// what is matter? never mind.
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 5000055
#define inf 0x3f3f3f3f
/*
0 : R
1 : L
*/
int n;
ll res,val[maxn];
char s[maxn];
pii st[maxn];
int m;
void add(int x,int y){
// cout<<"add "<<x<<" "<<y<<"\n";
if(m && st[m].se==0 && y==1 && (x-st[m].fi)%4==0){
res+=(x-st[m].fi)/4;
--m;
return;
}
st[++m]=mkp(x,y);
}
struct node{
int l,r,op,c;
}a[maxn];
ll f[2],pos[2],g[2];
signed main()
{
scanf("%s",s+1);n=strlen(s+1);
add(-1,1);
if(s[1]=='1')add(0,1);
For(i,2,n)
if(s[i-1]==s[i])add(i-1,s[i]&1);
if(s[n]=='0')add(n,0);
add(n+1,0);
// For(i,1,m)cout<<st[i].fi<<" "<<st[i].se<<"\n";
Rep(i,m-1,1)
if(st[i].se==0 && st[i+1].se==0){
int d=(st[i+1].fi-st[i].fi)/4;
res+=d;
st[i].fi+=d*4;
}
For(i,1,m-1)
if(st[i].se==1 && st[i+1].se==1){
int d=(st[i+1].fi-st[i].fi)/4;
res+=d;
st[i+1].fi-=d*4;
}
// cout<<"res "<<res<<"\n";
For(i,6,n+2) val[i]=val[(i-2)/4*4]+(i-2)/4;
int m2=0;
for(int l=1,r;l<=m;l=r+1){
r=l;
while(r+1<=m && st[r+1].se==st[l].se)++r;
a[++m2]={st[l].fi,st[r].fi,st[l].se,r-l+1};
}
m=m2;
pos[0]=pos[1]=a[1].r;
// For(i,1,m)cout<<a[i].l<<" "<<a[i].r<<" "<<a[i].op<<"\n";
// cout<<"laspos "<<pos[0]<<" "<<pos[1]<<"\n";
for(int i=2;i<m;i+=2){
int t=(a[i+1].l-a[i].r)/4;
g[0]=g[1]=-inf;
For(j,0,1) g[0]=max(g[0],f[j]+val[a[i].l+t*4-pos[j]]);
g[0]+=t*a[i].c;
For(j,0,1) g[1]=max(g[1],f[j]+val[a[i].l-pos[j]]);
g[1]+=t*a[i+1].c;
f[0]=g[0];
f[1]=g[1];
pos[0]=a[i+1].r;
pos[1]=a[i+1].r-t*4;
// cout<<"f: "<<f[0]<<" "<<f[1]<<"\n";
// cout<<"pos: "<<pos[0]<<" "<<pos[1]<<"\n";
}
For(i,0,1) f[i]+=val[a[m].l-pos[i]];
res+=max(f[0],f[1]);
cout<<res;
return 0;
}
/*
0000010101100110101101010110000110100111000010010111111100101101110101000111101111010101010010101010
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3764kb
input:
10100010011001011111
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
0000010101100110101101010110000110100111000010010111111100101101110101000111101111010101010010101010
output:
58
result:
ok 1 number(s): "58"
Test #3:
score: 0
Accepted
time: 11ms
memory: 18456kb
input:
100011000011001011010100111110011001000110111101101001100000110101101001101111100101110001101101000001001011011111001100111010101111001110000110001100101100101001001110000111100001100110000101111110001010101100100110010001110011101011110011101111000111010111100110100011110000011111110000111110111110...
output:
302244
result:
ok 1 number(s): "302244"
Test #4:
score: 0
Accepted
time: 5ms
memory: 13632kb
input:
100101010101010101010101010101010101010101100101101010101101010110101001001010101010101101010101010010101010010101010110101010101010101010101101010110101010101010101010101010101010101010101010101010101010101010101010101010101011010101010101010101010101011010010101110101010110101010101010101010111010...
output:
3328566
result:
ok 1 number(s): "3328566"
Test #5:
score: 0
Accepted
time: 4ms
memory: 12428kb
input:
101010101010101010101101010101010101010101010101010101010100101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101001010101010101010101010101010101010101010101010101010101010110...
output:
36918913
result:
ok 1 number(s): "36918913"
Test #6:
score: 0
Accepted
time: 3ms
memory: 12628kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
371689423
result:
ok 1 number(s): "371689423"
Test #7:
score: 0
Accepted
time: 0ms
memory: 12572kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
3378077368
result:
ok 1 number(s): "3378077368"
Test #8:
score: 0
Accepted
time: 0ms
memory: 12592kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
31250155082
result:
ok 1 number(s): "31250155082"
Test #9:
score: 0
Accepted
time: 0ms
memory: 12400kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
21976748120
result:
ok 1 number(s): "21976748120"
Test #10:
score: 0
Accepted
time: 0ms
memory: 12464kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
31249989871
result:
ok 1 number(s): "31249989871"
Test #11:
score: 0
Accepted
time: 0ms
memory: 12496kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
15417990032
result:
ok 1 number(s): "15417990032"
Test #12:
score: 0
Accepted
time: 3ms
memory: 12576kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
31249770935
result:
ok 1 number(s): "31249770935"
Test #13:
score: 0
Accepted
time: 59ms
memory: 77072kb
input:
001001110010100110000111011111010010000100110011010111100100011110101100000001000011001011010000100101101110001010011110010000000101110101101101001011000101011000001001110011001101111010111010000100011011111101101001000001111000001101100011011011111100001000000011001111110000100001111110111000011110...
output:
1529176
result:
ok 1 number(s): "1529176"
Test #14:
score: 0
Accepted
time: 53ms
memory: 66852kb
input:
111100101110111001010010100101010101110101100100011110100001010110101101000010100111001101110011011010010101100101010111001001100111001010111010100111010001110110000001001100001010000101011011010101010011000111010111111011011000010101101001010101010101111010101100101000010100101101110101110101011100...
output:
3453809
result:
ok 1 number(s): "3453809"
Test #15:
score: 0
Accepted
time: 28ms
memory: 58684kb
input:
010100110101010101111100101010101010010100101010010101010010010101011010101010100101010101010011100110101011010011100101010101001010101010110011001010101101101110101010101010101010100101010101100100101010101100010101001010101010101010110100101001010010100101101010101010101010101011101001010101101010...
output:
7267243
result:
ok 1 number(s): "7267243"
Test #16:
score: 0
Accepted
time: 34ms
memory: 55244kb
input:
101100101010101010100010101010101001101010101010101010101101011010100101010101001010110101010101011011001010010101010101010001101010010010101010101101010100010101010101010100101010100101010101010101010101010010101000101010111010010110100101001010101101010101010110101001001010101001101010101010101010...
output:
11025428
result:
ok 1 number(s): "11025428"
Test #17:
score: 0
Accepted
time: 19ms
memory: 53008kb
input:
101010101010101101001010101010101011010110010101001010101010100101010101010101010101010101010101010101010110101010101010101010101010101010110101010101010101010101010011010010101010110101010101001010110101010010101010100101011101010110101010010100101010010101101010101010101010101101010101010011010101...
output:
16770603
result:
ok 1 number(s): "16770603"
Test #18:
score: 0
Accepted
time: 14ms
memory: 48224kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101001010101010101010101010101010101010101010101010101010101010101010101010101010110101001010101010101010101010101010101010101010101010101010101010101...
output:
188646665
result:
ok 1 number(s): "188646665"
Test #19:
score: 0
Accepted
time: 24ms
memory: 47556kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010110101010101010101010101010101010101010101010101010101010101010101010101010101010101010100101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
1815374361
result:
ok 1 number(s): "1815374361"
Test #20:
score: 0
Accepted
time: 19ms
memory: 47512kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
16307938305
result:
ok 1 number(s): "16307938305"
Test #21:
score: 0
Accepted
time: 15ms
memory: 47716kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
184171987292
result:
ok 1 number(s): "184171987292"
Test #22:
score: 0
Accepted
time: 11ms
memory: 47676kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
128638532514
result:
ok 1 number(s): "128638532514"
Test #23:
score: 0
Accepted
time: 7ms
memory: 47552kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
434363327492
result:
ok 1 number(s): "434363327492"
Test #24:
score: 0
Accepted
time: 15ms
memory: 47776kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
493093081142
result:
ok 1 number(s): "493093081142"
Test #25:
score: 0
Accepted
time: 17ms
memory: 47636kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
669857207760
result:
ok 1 number(s): "669857207760"
Test #26:
score: 0
Accepted
time: 13ms
memory: 47720kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
468842033630
result:
ok 1 number(s): "468842033630"
Test #27:
score: 0
Accepted
time: 8ms
memory: 47680kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
639985723182
result:
ok 1 number(s): "639985723182"
Test #28:
score: 0
Accepted
time: 15ms
memory: 47752kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
391921131742
result:
ok 1 number(s): "391921131742"
Test #29:
score: 0
Accepted
time: 17ms
memory: 47772kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
781249375000
result:
ok 1 number(s): "781249375000"
Test #30:
score: 0
Accepted
time: 8ms
memory: 47640kb
input:
101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010...
output:
781249997600
result:
ok 1 number(s): "781249997600"
Extra Test:
score: 0
Extra Test Passed