思路:
水题;
代码:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; #define maxn 200005 int ai[maxn],bi[maxn],ci[maxn],n; inline void in(int &now)
{
char Cget=getchar();now=;
while(Cget>''||Cget<'') Cget=getchar();
while(Cget>=''&&Cget<='')
{
now=now*+Cget-'';
Cget=getchar();
}
} int main()
{
in(n);int cnt=maxn+,pos=maxn+;
for(int i=;i<=n;i++) in(ai[i]);
for(int i=;i<=n;i++) bi[i]=ai[i]?++cnt:cnt=;
for(int i=n;i>=;i--) ci[i]=ai[i]?++pos:pos=;
for(int i=;i<=n;i++) printf("%d ",min(bi[i],ci[i]));
return ;
}