ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#190152 | #3312. 圆 | yy | 100 | 664ms | 2132kb | C++11 | 754b | 2023-10-05 10:52:06 | 2023-10-05 12:47:00 |
answer
#include<bits/stdc++.h>
using namespace std;
int n, t, idx, a[1000001];
long long ans;
bool f, flag=true;
string s;
int main()
{
scanf("%d",&n);
cin>>s;
for(int i=0;i<n;i++)
{
if(s[i]=='0')
{
t++,ans++;
if(i==0)
f=1;
}
else if(t)
{
a[++idx]=t;
t=0;
flag=false;
}
else
flag=false;
}
if(f)
{
a[1]+=t;
idx=max(idx,1);
}
else
a[++idx]=t;
if(flag)
{
for(int i=1;i<=n;i++)
{
ans=n-i+1;
ans*=n;
printf("%lld\n",ans);
}
return 0;
}
sort(a+1,a+idx+1);
for(int i=1;i<=n;i++)
{
ans=0;
for(int j=idx;j>=1;j--)
{
if((a[j]+1)/i>=2)
ans+=a[j]-(i-1)*2;
else
break;
}
printf("%lld\n",ans*(n-i+1));
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1280kb
input:
100 000000000000000000000000001000000000000000010000110000000000000000000000000000000000000000000000...
output:
9600 8910 8232 7760 7296 6840 6392 5952 5520 5278 5040 4806 4576 4350 4128 3910 3696 3486 3280 3078 ...
result:
ok 100 lines
Test #2:
score: 10
Accepted
time: 0ms
memory: 1284kb
input:
100 111000000000000000001100000000000001111100000000000100000000000000000000000010000000000000000000...
output:
8800 7722 6664 5626 4608 3610 2726 2046 1472 1001 630 267 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 100 lines
Test #3:
score: 10
Accepted
time: 0ms
memory: 1284kb
input:
1000 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
966000 930069 897202 865396 839628 814905 790230 765603 741024 716493 693000 672520 654056 635628 61...
result:
ok 1000 lines
Test #4:
score: 10
Accepted
time: 0ms
memory: 1284kb
input:
1000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
968000 939060 914168 889324 864528 841770 819056 796386 773760 751178 730620 710102 689624 669186 64...
result:
ok 1000 lines
Test #5:
score: 10
Accepted
time: 117ms
memory: 2128kb
input:
1000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
999941000000 999877000122 999818000360 999763000702 999708001152 999653001710 999598002376 999543003...
result:
ok 1000000 lines
Test #6:
score: 10
Accepted
time: 104ms
memory: 2128kb
input:
1000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
999945000000 999888000111 999833000330 999778000657 999723001092 999668001635 999613002286 999558003...
result:
ok 1000000 lines
Test #7:
score: 10
Accepted
time: 99ms
memory: 2132kb
input:
1000000 11110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
999996000000 999993000006 999990000016 999987000030 999984000048 999981000070 999978000096 999975000...
result:
ok 1000000 lines
Test #8:
score: 10
Accepted
time: 123ms
memory: 2128kb
input:
1000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
999935000000 999876000123 999817000362 999760000711 999703001172 999646001745 999589002430 999534003...
result:
ok 1000000 lines
Test #9:
score: 10
Accepted
time: 109ms
memory: 2128kb
input:
1000000 10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
999968000000 999945000054 999922000152 999899000294 999876000480 999853000710 999830000984 999807001...
result:
ok 1000000 lines
Test #10:
score: 10
Accepted
time: 112ms
memory: 2132kb
input:
1000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...
output:
1000000000000 999999000000 999998000000 999997000000 999996000000 999995000000 999994000000 99999300...
result:
ok 1000000 lines
Extra Test:
score: 0
Extra Test Passed