Playoff - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
读入n,代表有2^n个队伍参加比赛,每次相邻的两个队比赛,字符串中0->分低的胜利,1->分高的胜利路
对于a<b<c<d;字符串是01或者10,可以发现都只有b,c可以赢得比赛,字符串中01的顺序对答案没有影响
1的个数x->使得前[1,2^x)都会被淘汰掉
0的个数y->使得后面(2^n-2^y+1,2^n]都被淘汰掉
最终留下[2^x,2^n - 2^y +1 ]
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#define x first
#define int long long
#define y second
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<char,int> PCI;
typedef pair<LL,LL> PLL;
//typedef __int128 i128;
typedef unsigned long long ULL;
const int N=2e5+10,INF = 1e9 ,mod = 1e9 + 7 ,P = 131;
const double eps = 1e-7;
int p[N],q[N];
vector<int> pos[N];
int n;
void solve()
{
string s;
cin >> n >> s ;
int k = count(s.begin(),s.end(),'1');
for(int x = 1 << k ;x <= (1<<n) - (1<<(n-k)) + 1;x ++ )
cout << x << " ";
}
signed main()
{
// freopen("1.txt","r",stdin);
ios
LL T=1;
// cin>>T;
while(T -- )
{
solve();
}
return 0;
}