题解:P17867 [FJCPC 2026] 哦 搞错了
chenzhixuan2010 · · 题解
简单构造题。
考虑使所有为
由于每个
- 若
S_i = 0 ,则令A_i = i 。 - 若
S_i = 1 ,则令A_i = 2^k + i 。其中k 可以取任意大于\log_2 n 且小于60 的数,这里我取了58 。
对于最后一位,根据前面
::::success[code]
#include<bits/stdc++.h>
#define int long long
using namespace std;
namespace Fast{
inline int fr(){
int x = 0,f = 1;
char c = getchar();
while (c < '0' || c > '9'){
if (c == '-') f = 0;
c = getchar();
}
while (c >= '0' && c <= '9'){
x = (x << 1) + (x << 3) + (c ^ 48);
c = getchar();
}
return (f ? x : -x);
}
char putstk[1005];
inline void fw(int x){
if (x == 0) return putchar('0'),void();
if (x < 0) x = -x,putchar('-');
int tp = 0;
while (x) putstk[++tp] = ((x % 10) ^ 48),x /= 10LL;
while (tp) putchar(putstk[tp--]);
}
}
using namespace Fast;
int a[114514];
signed main(){
string s;
cin>>s;
int n = s.size();
s = ' ' + s;
int cnt1 = 0;
for (int i = 1;i < n;i++){
int res = i;
if (s[i] == '0') a[i] = res;
else a[i] = res + (1LL << 58),cnt1++;
}
if (cnt1 % 2 == 0) a[n] = ((1LL << 58) + n);
else a[n] = n;
for (int i = 1;i <= n;i++) fw(a[i]),putchar(' ');
return 0;
}
::::