AT_abc465_c 题解
好像有很多人 splay 板子直接过去的,这波真吓哭了,什么时候 C 这么超标了??
我们考虑一个 虽然我赛时五分多钟才反应过来。
然后你考虑这一个
本质就是分奇偶性加加减减的一个式子,我们根据下标奇偶性对每个
然后就做完了,实现有点点小细节,具体可以看下代码。
::::success[code && submission]
#include<bits/stdc++.h>
#define LL long long
#define UInt unsigned int
#define ULL unsigned long long
#define LD long double
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define pDD pair<LD,LD>
#define fr first
#define se second
#define pb push_back
#define isr insert
#define _i128 __int128
using namespace std;
const int N = 5e5+5;
int n,p[N],cnt,s[2][N];
int ans[N];
string str;
int read(){
int su=0,pp=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')pp=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){su=su*10+ch-'0';ch=getchar();}
return su*pp;
}
int main(){
n=read();
cin>>str;str=" "+str;
for(int i=1;i<=n;i++)
if(str[i]=='o')p[++cnt]=i;
for(int i=cnt;i>=1;i--)
s[i%2][i]=s[i%2][i+2]+p[i]+1;
for(int i=1;i<=n;i++){
int id=lower_bound(p+1,p+cnt+1,i)-p;
if(id<1||id>cnt){ans[i]=i;continue;}
int cc=cnt-id+1,now=0;
int opt=id%2;
if(cc%2==0)
now=s[1-opt][id+1]-s[opt][id]+i;
else
now=s[opt][id]-s[1-opt][id+1]-i;
ans[now]=i;
}
for(int i=1;i<=n;i++)
cout<<ans[i]<<" ";cout<<"\n";
return 0;
}
::::
如果本篇题解对你有帮助的话,麻烦你点一个小小的赞,真是太感谢啦!